Skip to content

Commit b0fb9f1

Browse files
authored
Separate and merge .h/.hpp files in duckdb (#8566)
- Merge small .h files into vortex_duckdb.h - Separate C++ code not used in bindgen to .hpp files - Remove dead code from duckdb: duckdb_vector_to_string, Config, ClientContext, duckdb_vx_add_extension_option, DDBString creation. - Remove rest duckdbfs code. Duckdbfs was partially removed in #8468 but the Rust-side code survived. Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
1 parent 4457a4a commit b0fb9f1

59 files changed

Lines changed: 535 additions & 1836 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/duckdb-bench/src/lib.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use vortex_bench::Format;
1616
use vortex_bench::IdempotentPath;
1717
use vortex_bench::generate_duckdb_registration_sql;
1818
use vortex_bench::runner::BenchmarkQueryResult;
19-
use vortex_duckdb::duckdb::Config;
2019
use vortex_duckdb::duckdb::Connection;
2120
use vortex_duckdb::duckdb::Database;
2221
use vortex_duckdb::duckdb::QueryResult;
@@ -75,30 +74,21 @@ impl DuckClient {
7574
path: Option<PathBuf>,
7675
threads: Option<usize>,
7776
) -> Result<(Database, Connection)> {
78-
let mut config = Config::new().vortex_expect("failed to create duckdb config");
79-
80-
// Set DuckDB thread count if specified
81-
if let Some(thread_count) = threads {
82-
config.set("threads", &format!("{}", thread_count))?;
83-
}
84-
8577
let db = match path {
86-
Some(path) => Database::open_with_config(path, config),
87-
None => Database::open_in_memory_with_config(config),
78+
Some(path) => Database::open(path),
79+
None => Database::open_in_memory(),
8880
}?;
8981

9082
let connection = db.connect()?;
9183
vortex_duckdb::initialize(&db)?;
9284

93-
// Enable Parquet metadata cache for all benchmark runs.
94-
//
85+
if let Some(thread_count) = threads {
86+
connection.query(&format!("SET threads = {thread_count}"))?;
87+
}
88+
9589
// `parquet_metadata_cache` is an extension-specific option that's
9690
// only available after the Parquet extension is loaded. The Parquet
9791
// extension is loaded after the connection is established.
98-
//
99-
// Passing the option to `open_with_config` before leads to
100-
// "Invalid Input Error: The following options were not recognized:
101-
// parquet_metadata_cache" when running DuckDB in debug mode.
10292
connection.query("SET parquet_metadata_cache = true")?;
10393

10494
Ok((db, connection))

vortex-duckdb/build.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,19 @@ const DEFAULT_DUCKDB_VERSION: &str = "1.5.3";
2727

2828
const BUILD_ARTIFACTS: [&str; 3] = ["libduckdb.dylib", "libduckdb.so", "libduckdb_static.a"];
2929

30-
const SOURCE_FILES: [&str; 18] = [
31-
"cpp/client_context.cpp",
32-
"cpp/config.cpp",
30+
const SOURCE_FILES: [&str; 7] = [
31+
"cpp/vortex_duckdb.cpp",
3332
"cpp/copy_function.cpp",
34-
"cpp/data.cpp",
35-
"cpp/data_chunk.cpp",
36-
"cpp/error.cpp",
3733
"cpp/expr.cpp",
38-
"cpp/file_system.cpp",
39-
"cpp/logical_type.cpp",
4034
"cpp/optimizer.cpp",
41-
"cpp/replacement_scan.cpp",
42-
"cpp/reusable_dict.cpp",
43-
"cpp/scalar_function.cpp",
4435
"cpp/table_filter.cpp",
4536
"cpp/table_function.cpp",
46-
"cpp/value.cpp",
4737
"cpp/vector.cpp",
48-
"cpp/vector_buffer.cpp",
4938
];
5039

5140
// Duckdb C API function we use.
5241
// This lowers codegen'd src/cpp.rs by four times.
53-
const DUCKDB_C_API_FUNCTIONS: [&str; 134] = [
42+
const DUCKDB_C_API_FUNCTIONS: [&str; 133] = [
5443
"duckdb_array_type_array_size",
5544
"duckdb_array_type_child_type",
5645
"duckdb_array_vector_get_child",
@@ -184,7 +173,16 @@ const DUCKDB_C_API_FUNCTIONS: [&str; 134] = [
184173
"duckdb_vector_reference_value",
185174
"duckdb_vector_reference_vector",
186175
"duckdb_vector_size",
187-
"duckdb_vector_to_string",
176+
];
177+
178+
const DUCKDB_C_API_HEADERS: [&str; 7] = [
179+
"cpp/include/vortex_duckdb.h",
180+
"cpp/include/expr.h",
181+
"cpp/include/table_filter.h",
182+
"cpp/include/vector.h",
183+
"cpp/include/copy_function.h",
184+
"cpp/include/table_function.h",
185+
"cpp/include/optimizer.h",
188186
];
189187

190188
const DOWNLOAD_MAX_RETRIES: i32 = 3;
@@ -462,7 +460,7 @@ fn try_build_duckdb(
462460
/// Generate rust functions with bindgen from C sources.
463461
fn bindgen_c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
464462
let mut builder = bindgen::Builder::default()
465-
.header("cpp/include/duckdb_vx.h")
463+
.headers(DUCKDB_C_API_HEADERS)
466464
.override_abi(Abi::CUnwind, ".*")
467465
.raw_line("#![allow(dead_code)]")
468466
.raw_line("#![allow(non_camel_case_types)]")

vortex-duckdb/cpp/client_context.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

vortex-duckdb/cpp/config.cpp

Lines changed: 0 additions & 153 deletions
This file was deleted.

vortex-duckdb/cpp/copy_function.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3-
#include "duckdb_vx/data.hpp"
4-
#include "duckdb_vx/error.hpp"
5-
#include "duckdb_vx/table_function.h"
3+
#include "data.hpp"
4+
#include "error.hpp"
5+
#include "vortex_duckdb.h"
6+
#include "table_function.h"
67
#include "vortex.h"
78
#include "duckdb/function/copy_function.hpp"
89
#include "duckdb/main/capi/capi_internal.hpp"
@@ -11,8 +12,6 @@
1112
#include "duckdb/parser/parsed_data/create_copy_function_info.hpp"
1213

1314
using namespace duckdb;
14-
using vortex::CData;
15-
using vortex::IntoErrString;
1615

1716
struct CopyBindData final : TableFunctionData {
1817
CopyBindData(unique_ptr<CData> ffi_data) : ffi_data(std::move(ffi_data)) {

vortex-duckdb/cpp/data.cpp

Lines changed: 0 additions & 29 deletions
This file was deleted.

vortex-duckdb/cpp/data_chunk.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)