diff --git a/vortex-cxx/CMakeLists.txt b/vortex-cxx/CMakeLists.txt index 9d5a4eb02d2..ab5474d0617 100644 --- a/vortex-cxx/CMakeLists.txt +++ b/vortex-cxx/CMakeLists.txt @@ -10,6 +10,7 @@ project(vortex) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_program(SCCACHE_PROGRAM sccache) if (SCCACHE_PROGRAM) @@ -24,7 +25,7 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -Wno-dollar-in-identifier-extension") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-dollar-in-identifier-extension") option(VORTEX_ENABLE_TESTING "Enable building test binary for vortex-cxx" OFF) option(VORTEX_ENABLE_ASAN "Enable address sanitizer" OFF) diff --git a/vortex-cxx/cpp/src/expr.cpp b/vortex-cxx/cpp/src/expr.cpp index 19a8aae8ec4..0e2d67395c1 100644 --- a/vortex-cxx/cpp/src/expr.cpp +++ b/vortex-cxx/cpp/src/expr.cpp @@ -50,7 +50,8 @@ DEFINE_BINARY_OP(checked_add) Expr select(const std::vector &fields, Expr child) { ::rust::Vec<::rust::String> rs_fields; - for (auto f : fields) { + rs_fields.reserve(fields.size()); + for (std::string_view f : fields) { rs_fields.emplace_back(f.data(), f.length()); } return Expr(ffi::select(rs_fields, std::move(child).IntoImpl())); diff --git a/vortex-cxx/examples/CMakeLists.txt b/vortex-cxx/examples/CMakeLists.txt index 2da1b30f3e7..348d80e1547 100644 --- a/vortex-cxx/examples/CMakeLists.txt +++ b/vortex-cxx/examples/CMakeLists.txt @@ -8,7 +8,6 @@ project(vortex-examples) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) - find_program(SCCACHE_PROGRAM sccache) if (SCCACHE_PROGRAM) set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}") @@ -32,6 +31,4 @@ if(APPLE) set(APPLE_LINK_FLAGS "-framework CoreFoundation -framework Security") endif() - target_link_libraries(hello-vortex PRIVATE vortex ${APPLE_LINK_FLAGS}) - diff --git a/vortex-duckdb/cpp/CMakeLists.txt b/vortex-duckdb/cpp/CMakeLists.txt index e0a40c4c918..9671d93dd6d 100644 --- a/vortex-duckdb/cpp/CMakeLists.txt +++ b/vortex-duckdb/cpp/CMakeLists.txt @@ -10,20 +10,20 @@ # If your editor relies on a compilation database to enable LSP functionality, # you can generate it by running `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON` or # `bear -- cargo build` (https://github.com/rizsotto/Bear). - -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.22) project(vortex_duckdb_cpp) set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Default to debug if build config is not explicitly set. if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) -endif () +endif() # Enable compiler warnings (matching build.rs flags). -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") # Find DuckDB include directory via the symlink created by build.rs. # The symlink points to target/duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/ diff --git a/vortex-duckdb/cpp/config.cpp b/vortex-duckdb/cpp/config.cpp index 1761ae76456..c2d2c72169f 100644 --- a/vortex-duckdb/cpp/config.cpp +++ b/vortex-duckdb/cpp/config.cpp @@ -46,16 +46,15 @@ duckdb_state duckdb_vx_get_config_value(duckdb_config config, const char *key, d std::string key_str(key); // First check set_variable_defaults (the primary location for config values) - auto set_it = db_config->options.set_variable_defaults.find(key_str); - if (set_it != db_config->options.set_variable_defaults.end()) { - *out_value = reinterpret_cast(new Value(set_it->second)); + if (db_config->options.set_variable_defaults.contains(key_str)) { + *out_value = + reinterpret_cast(new Value(db_config->options.set_variable_defaults[key_str])); return DuckDBSuccess; } // Then check user_options - auto user_it = db_config->options.user_options.find(key_str); - if (user_it != db_config->options.user_options.end()) { - *out_value = reinterpret_cast(new Value(user_it->second)); + if (db_config->options.user_options.contains(key_str)) { + *out_value = reinterpret_cast(new Value(db_config->options.user_options[key_str])); return DuckDBSuccess; } @@ -81,13 +80,12 @@ int duckdb_vx_config_has_key(duckdb_config config, const char *key) { std::string key_str(key); // Check if the key exists in set_variable_defaults (primary location) - if (db_config->options.set_variable_defaults.find(key_str) != - db_config->options.set_variable_defaults.end()) { + if (db_config->options.set_variable_defaults.contains(key_str)) { return 1; } // Check if the key exists in user_options - if (db_config->options.user_options.find(key_str) != db_config->options.user_options.end()) { + if (db_config->options.user_options.contains(key_str)) { return 1; } diff --git a/vortex-duckdb/cpp/table_function.cpp b/vortex-duckdb/cpp/table_function.cpp index aececf46f3e..fc4ac1b66da 100644 --- a/vortex-duckdb/cpp/table_function.cpp +++ b/vortex-duckdb/cpp/table_function.cpp @@ -204,12 +204,8 @@ void c_pushdown_complex_filter(ClientContext & /*context*/, throw BinderException(IntoErrString(error_out)); } - if (pushed) { - // If the pushdown complex filter returns true, we can remove the filter from the list. - iter = filters.erase(iter); - } else { - ++iter; - } + // If the pushdown complex filter returns true, we can remove the filter from the list. + iter = pushed ? filters.erase(iter) : std::next(iter); } } @@ -257,11 +253,10 @@ extern "C" duckdb_value duckdb_vx_tfunc_bind_input_get_named_parameter(duckdb_vx } const auto info = reinterpret_cast(ffi_input); - auto t = info->named_parameters.find(name); - if (t == info->named_parameters.end()) { + if (!info->named_parameters.contains(name)) { return nullptr; } - auto value = duckdb::make_uniq(t->second); + auto value = duckdb::make_uniq(info->named_parameters.at(name)); return reinterpret_cast(value.release()); }