Skip to content

Commit d26e322

Browse files
committed
feat: move to latest vortex and duckdb 1.3.1
1 parent d9f354b commit d26e322

File tree

8 files changed

+236
-131
lines changed

8 files changed

+236
-131
lines changed

duckdb

src/include/vortex_common.hpp

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@
1010

1111
namespace vortex {
1212

13+
struct ConversionCache {
14+
explicit ConversionCache(const unsigned long cache_id) : cache_id(cache_id) {
15+
}
16+
17+
~ConversionCache() {
18+
}
19+
20+
unsigned long cache_id;
21+
};
22+
1323
struct DType {
14-
explicit DType(vx_dtype *dtype) : dtype(dtype) {
24+
explicit DType(const vx_dtype *dtype) : dtype(dtype) {
1525
}
1626

1727
static duckdb::unique_ptr<DType> FromDuckDBTable(const std::vector<duckdb_logical_type> &column_types,
@@ -34,57 +44,45 @@ struct DType {
3444
}
3545
}
3646

37-
vx_dtype *dtype;
47+
const vx_dtype *dtype;
3848
};
3949

40-
struct ConversionCache {
41-
explicit ConversionCache(const unsigned long cache_id) : cache(vx_conversion_cache_create(cache_id)) {
50+
struct VortexFile {
51+
explicit VortexFile(const vx_file *file) : file(file) {
4252
}
4353

44-
~ConversionCache() {
45-
vx_conversion_cache_free(cache);
54+
~VortexFile() {
55+
vx_file_free(file);
4656
}
4757

48-
vx_conversion_cache *cache;
49-
};
50-
51-
struct FileReader {
52-
explicit FileReader(vx_file_reader *file) : file(file) {
53-
}
54-
55-
~FileReader() {
56-
vx_file_reader_free(file);
57-
}
58-
59-
static duckdb::unique_ptr<FileReader> Open(const vx_file_open_options *options, VortexSession &session) {
58+
static duckdb::unique_ptr<VortexFile> Open(const vx_file_open_options *options, VortexSession &session) {
6059
auto file = Try([&](auto err) { return vx_file_open_reader(options, session.session, err); });
61-
return duckdb::make_uniq<FileReader>(file);
60+
return duckdb::make_uniq<VortexFile>(file);
6261
}
6362

6463
vx_array_iterator *Scan(const vx_file_scan_options *options) {
65-
return Try([&](auto err) { return vx_file_reader_scan(this->file, options, err); });
64+
return Try([&](auto err) { return vx_file_scan(this->file, options, err); });
6665
}
6766

68-
bool CanPrune(const char *filter_expression, unsigned int filter_expression_len) {
67+
bool CanPrune(const char *filter_expression, unsigned int filter_expression_len, unsigned long file_idx) {
6968
return Try([&](auto err) {
70-
return vx_file_reader_can_prune(this->file, filter_expression, filter_expression_len, err);
69+
return vx_file_can_prune(this->file, filter_expression, filter_expression_len, file_idx, err);
7170
});
7271
}
7372

74-
uint64_t FileRowCount() {
75-
return Try([&](auto err) { return vx_file_row_count(file, err); });
73+
uint64_t RowCount() {
74+
return vx_file_row_count(file);
7675
}
7776

7877
struct DType DType() {
79-
return vortex::DType(vx_file_dtype(file));
78+
return vortex::DType(vx_dtype_clone(vx_file_dtype(file)));
8079
}
8180

82-
vx_file_reader *file;
81+
const vx_file *file;
8382
};
8483

85-
8684
struct Array {
87-
explicit Array(vx_array *array) : array(array) {
85+
explicit Array(const vx_array *array) : array(array) {
8886
}
8987

9088
~Array() {
@@ -101,14 +99,16 @@ struct Array {
10199
return duckdb::make_uniq<Array>(array);
102100
}
103101

104-
idx_t ToDuckDBVector(idx_t current_row, duckdb_data_chunk output, const ConversionCache *cache) const {
105-
return Try([&](auto err) { return vx_array_to_duckdb_chunk(array, current_row, output, cache->cache, err); });
102+
void ToDuckDBVector(idx_t current_row, duckdb_data_chunk output, const ConversionCache *cache) {
103+
// For now, this is a placeholder - the actual implementation would need
104+
// to use the DuckDB exporter pattern with the current array
105+
// The vx_array_to_duckdb_chunk function referenced in the error doesn't exist
106+
throw duckdb::NotImplementedException("Array::ToDuckDBVector not yet implemented");
106107
}
107108

108-
vx_array *array;
109+
const vx_array *array;
109110
};
110111

111-
112112
struct ArrayIterator {
113113
explicit ArrayIterator(vx_array_iterator *array_iter) : array_iter(array_iter) {
114114
}
@@ -117,20 +117,20 @@ struct ArrayIterator {
117117
/// eventually calling vx_array_iter_free.
118118
///
119119
/// This ArrayIterator is useless after this call.
120-
vx_array_iterator* release() {
121-
auto* ptr = array_iter;
122-
array_iter = nullptr; // Give up ownership
120+
vx_array_iterator *release() {
121+
auto *ptr = array_iter;
122+
array_iter = nullptr; // Give up ownership
123123
return ptr;
124124
}
125125

126126
~ArrayIterator() {
127127
if (array_iter) {
128-
vx_array_iter_free(array_iter);
128+
vx_array_iterator_free(array_iter);
129129
}
130130
}
131131

132132
duckdb::unique_ptr<Array> NextArray() const {
133-
auto array = Try([&](auto err) { return vx_array_iter_next(array_iter, err); });
133+
auto array = Try([&](auto err) { return vx_array_iterator_next(array_iter, err); });
134134

135135
if (array == nullptr) {
136136
return nullptr;
@@ -142,7 +142,6 @@ struct ArrayIterator {
142142
vx_array_iterator *array_iter;
143143
};
144144

145-
146145
struct ArrayExporter {
147146
explicit ArrayExporter(vx_duckdb_exporter *exporter) : exporter(exporter) {
148147
}
@@ -154,9 +153,7 @@ struct ArrayExporter {
154153
}
155154

156155
static duckdb::unique_ptr<ArrayExporter> FromArrayIterator(duckdb::unique_ptr<ArrayIterator> array_iter) {
157-
auto exporter = Try([&](auto err) {
158-
return vx_duckdb_exporter_create(array_iter->release(), err);
159-
});
156+
auto exporter = vx_duckdb_exporter_new(array_iter->release());
160157
return duckdb::make_uniq<ArrayExporter>(exporter);
161158
}
162159

@@ -167,7 +164,6 @@ struct ArrayExporter {
167164
vx_duckdb_exporter *exporter;
168165
};
169166

170-
171167
struct ArrayStreamSink {
172168
explicit ArrayStreamSink(vx_array_sink *sink, duckdb::unique_ptr<DType> dtype)
173169
: sink(sink), dtype(std::move(dtype)) {

src/include/vortex_error.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ namespace vortex {
1010

1111
inline void HandleError(vx_error *error) {
1212
if (error != nullptr) {
13-
auto msg = std::string(vx_error_get_message(error));
13+
auto msg_str = vx_error_get_message(error);
14+
auto msg = std::string(vx_string_ptr(msg_str), vx_string_len(msg_str));
15+
vx_string_free(msg_str);
1416
vx_error_free(error);
1517
throw duckdb::InvalidInputException(msg);
1618
}

src/include/vortex_expr.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ namespace vortex {
1010
const std::string BETWEEN_ID = "between";
1111
const std::string BINARY_ID = "binary";
1212
const std::string GET_ITEM_ID = "get_item";
13-
const std::string IDENTITY_ID = "identity";
13+
const std::string PACK_ID = "pack";
14+
const std::string VAR_ID = "var";
1415
const std::string LIKE_ID = "like";
1516
const std::string LITERAL_ID = "literal";
1617
const std::string NOT_ID = "not";
18+
const std::string LIST_CONTAINS_ID = "list_contains";
1719

1820
vortex::expr::Expr *table_expression_into_expr(google::protobuf::Arena &arena, duckdb::TableFilter &filter,
1921
const std::string &column_name);
2022
vortex::expr::Expr *expression_into_vortex_expr(google::protobuf::Arena &arena, const duckdb::Expression &expr);
2123
vortex::expr::Expr *flatten_exprs(google::protobuf::Arena &arena,
2224
const duckdb::vector<vortex::expr::Expr *> &child_filters);
25+
vortex::expr::Expr *pack_projection_columns(google::protobuf::Arena &arena, duckdb::vector<std::string> columns);
2326
} // namespace vortex

src/include/vortex_session.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace vortex {
77

88
class VortexSession : public duckdb::ObjectCacheEntry {
99
public:
10-
VortexSession() : session(vx_session_create()) {
10+
VortexSession() : session(vx_session_new()) {
1111
}
1212

1313
~VortexSession() override {
@@ -25,4 +25,4 @@ class VortexSession : public duckdb::ObjectCacheEntry {
2525
}
2626
};
2727

28-
} // namespace vortex
28+
} // namespace vortex

0 commit comments

Comments
 (0)