Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/include/vortex_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct FileReader {
vx_file_reader *file;
};


struct Array {
explicit Array(vx_array *array) : array(array) {
}
Expand All @@ -107,12 +108,25 @@ struct Array {
vx_array *array;
};


struct ArrayIterator {
explicit ArrayIterator(vx_array_iterator *array_iter) : array_iter(array_iter) {
}

/// Releases ownership of the native array iterator ptr to the caller. The caller is then responsible for
/// eventually calling vx_array_iter_free.
///
/// This ArrayIterator is useless after this call.
vx_array_iterator* release() {
auto* ptr = array_iter;
array_iter = nullptr; // Give up ownership
return ptr;
}

~ArrayIterator() {
vx_array_iter_free(array_iter);
if (array_iter) {
vx_array_iter_free(array_iter);
}
}

duckdb::unique_ptr<Array> NextArray() const {
Expand All @@ -128,6 +142,32 @@ struct ArrayIterator {
vx_array_iterator *array_iter;
};


struct ArrayExporter {
explicit ArrayExporter(vx_duckdb_exporter *exporter) : exporter(exporter) {
}

~ArrayExporter() {
if (exporter != nullptr) {
vx_duckdb_exporter_free(exporter);
}
}

static duckdb::unique_ptr<ArrayExporter> FromArrayIterator(duckdb::unique_ptr<ArrayIterator> array_iter) {
auto exporter = Try([&](auto err) {
return vx_duckdb_exporter_create(array_iter->release(), err);
});
return duckdb::make_uniq<ArrayExporter>(exporter);
}

bool ExportNext(duckdb_data_chunk output) const {
return Try([&](auto err) { return vx_duckdb_exporter_next(exporter, output, err); });
}

vx_duckdb_exporter *exporter;
};


struct ArrayStreamSink {
explicit ArrayStreamSink(vx_array_sink *sink, duckdb::unique_ptr<DType> dtype)
: sink(sink), dtype(std::move(dtype)) {
Expand Down
9 changes: 9 additions & 0 deletions src/include/vortex_expr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
#include "expr.pb.h"

namespace vortex {
// vortex expr proto ids.
const std::string BETWEEN_ID = "between";
const std::string BINARY_ID = "binary";
const std::string GET_ITEM_ID = "get_item";
const std::string IDENTITY_ID = "identity";
const std::string LIKE_ID = "like";
const std::string LITERAL_ID = "literal";
const std::string NOT_ID = "not";

vortex::expr::Expr *table_expression_into_expr(google::protobuf::Arena &arena, duckdb::TableFilter &filter,
const std::string &column_name);
vortex::expr::Expr *expression_into_vortex_expr(google::protobuf::Arena &arena, const duckdb::Expression &expr);
Expand Down
9 changes: 0 additions & 9 deletions src/vortex_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ using std::string;

namespace vortex {

// vortex expr proto ids.
const string BETWEEN_ID = "between";
const string BINARY_ID = "binary";
const string GET_ITEM_ID = "get_item";
const string IDENTITY_ID = "identity";
const string LIKE_ID = "like";
const string LITERAL_ID = "literal";
const string NOT_ID = "not";

// Temporal ids
const string VORTEX_DATE_ID = "vortex.date";
const string VORTEX_TIME_ID = "vortex.time";
Expand Down
Loading
Loading