Skip to content

Commit bcd2475

Browse files
committed
initial
1 parent 6efc235 commit bcd2475

File tree

24 files changed

+1696
-311
lines changed

24 files changed

+1696
-311
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ vortex-decimal-byte-parts = { version = "0.1.0", path = "encodings/decimal-byte-
265265
vortex-error = { version = "0.1.0", path = "./vortex-error", default-features = false }
266266
vortex-fastlanes = { version = "0.1.0", path = "./encodings/fastlanes", default-features = false }
267267
vortex-file = { version = "0.1.0", path = "./vortex-file", default-features = false }
268+
vortex-ffi = { version = "0.1.0", path = "./vortex-ffi", default-features = false }
268269
vortex-flatbuffers = { version = "0.1.0", path = "./vortex-flatbuffers", default-features = false }
269270
vortex-fsst = { version = "0.1.0", path = "./encodings/fsst", default-features = false }
270271
vortex-io = { version = "0.1.0", path = "./vortex-io", default-features = false }

vortex-array/src/dtype/field_names.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ impl From<Vec<&str>> for FieldNames {
341341
}
342342
}
343343

344+
impl From<Vec<String>> for FieldNames {
345+
fn from(value: Vec<String>) -> Self {
346+
Self(value.into_iter().map(FieldName::from).collect())
347+
}
348+
}
349+
344350
impl From<&[FieldName]> for FieldNames {
345351
fn from(value: &[FieldName]) -> Self {
346352
Self(Arc::from(value))

vortex-cxx/cpp/include/vortex/scan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ class ScanBuilder {
105105

106106
rust::Box<ffi::VortexScanBuilder> impl_;
107107
};
108-
} // namespace vortex
108+
} // namespace vortex

vortex-duckdb/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ parking_lot = { workspace = true }
3737
paste = { workspace = true }
3838
tracing = { workspace = true }
3939
url = { workspace = true }
40+
vortex-ffi = { workspace = true }
4041
vortex = { workspace = true, features = ["files", "tokio", "object_store"] }
4142
vortex-utils = { workspace = true, features = ["dashmap"] }
4243

@@ -55,6 +56,6 @@ workspace = true
5556
[build-dependencies]
5657
bindgen = { workspace = true }
5758
cbindgen = { workspace = true }
58-
cc = { workspace = true }
59+
cc = { workspace = true , features = ["parallel"] }
5960
reqwest = { workspace = true }
6061
zip = { workspace = true }

vortex-duckdb/build.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const SOURCE_FILES: [&str; 18] = [
4141
"cpp/vector_buffer.cpp",
4242
];
4343

44+
const FFI_INCLUDE: &str = "../vortex-ffi/cinclude";
45+
4446
const DOWNLOAD_MAX_RETRIES: i32 = 3;
4547
const DOWNLOAD_TIMEOUT: u64 = 90;
4648

@@ -302,6 +304,7 @@ fn c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
302304
.rustified_non_exhaustive_enum("DUCKDB_TYPE")
303305
.size_t_is_usize(true)
304306
.clang_arg(format!("-I{}", duckdb_include_dir.display()))
307+
.clang_arg(format!("-I{}", crate_dir.join(FFI_INCLUDE).display()))
305308
.clang_arg(format!("-I{}", crate_dir.join("cpp/include").display()))
306309
.generate_comments(true)
307310
// Tell cargo to invalidate the built crate whenever any of the
@@ -329,12 +332,18 @@ fn c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
329332
}
330333

331334
fn cpp(duckdb_include_dir: &Path) {
335+
//println!("cargo:rustc-link-arg=-fsanitize=address");
332336
cc::Build::new()
333337
.std("c++20")
334-
.flags(["-Wall", "-Wextra", "-Wpedantic"])
338+
// Duckdb sources fail -Wno-unused-parameter
339+
.flags(["-Wall", "-Wextra", "-Wpedantic", "-Wno-unused-parameter"])
340+
// TODO
341+
//.flag("-fsanitize=address")
335342
.cpp(true)
343+
.debug(true)
336344
.include(duckdb_include_dir)
337345
.include("cpp/include")
346+
.include(FFI_INCLUDE)
338347
.files(SOURCE_FILES)
339348
.compile("vortex-duckdb-extras");
340349
// bindgen generates rerun-if-changed for .h/.hpp files

vortex-duckdb/cpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (NOT CMAKE_BUILD_TYPE)
2323
endif()
2424

2525
# Enable compiler warnings (matching build.rs flags).
26-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
26+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter")
2727

2828
# Find DuckDB include directory via the symlink created by build.rs.
2929
# The symlink points to target/duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/
@@ -39,7 +39,7 @@ else()
3939
)
4040
endif()
4141

42-
include_directories(include ${DUCKDB_INCLUDE})
42+
include_directories(include ${DUCKDB_INCLUDE} ../../vortex-ffi/cinclude)
4343

4444
# Auto-discover C++ source files
4545
file(GLOB CPP_SOURCES "*.cpp")

vortex-duckdb/cpp/include/duckdb_vx/table_function.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,22 @@
1212
#include "error.h"
1313
#include "table_filter.h"
1414
#include "duckdb_vx/data.h"
15-
#include "duckdb_vx/client_context.h"
15+
#include "duckdb_vx/duckdb_diagnostics.h"
16+
17+
#ifdef __cplusplus
18+
DUCKDB_INCLUDES_BEGIN
19+
#include "duckdb/common/arrow/arrow.hpp"
20+
DUCKDB_INCLUDES_END
21+
22+
using FFI_ArrowSchema = ArrowSchema;
23+
using FFI_ArrowArrayStream = ArrowArrayStream;
24+
#else
25+
// TODO nanoarrow
26+
typedef void FFI_ArrowSchema;
27+
typedef void FFI_ArrowArrayStream;
28+
#endif
29+
30+
#include "vortex.h"
1631

1732
#ifdef __cplusplus /* If compiled as C++, use C ABI */
1833
extern "C" {
@@ -150,8 +165,6 @@ typedef struct {
150165
duckdb_vx_string_map (*to_string)(void *bind_data);
151166
// void *dynamic_to_string;
152167

153-
double (*table_scan_progress)(duckdb_client_context ctx, void *bind_data, void *global_state);
154-
155168
idx_t (*get_partition_data)(const void *bind_data,
156169
void *init_global_data,
157170
void *init_local_data,
@@ -171,6 +184,11 @@ typedef struct {
171184
bool sampling_pushdown;
172185
bool late_materialization;
173186
idx_t max_threads;
187+
188+
// PoC hack: retain Rust exporter code
189+
// return local batch id
190+
uint64_t (*export_array)(const vx_array *arr, duckdb_data_chunk chunk);
191+
174192
} duckdb_vx_tfunc_vtab_t;
175193

176194
// A single function for configuring the DuckDB table function vtable.

0 commit comments

Comments
 (0)