Skip to content

Commit 322e91d

Browse files
Merge branch 'develop' into nemo/geo-bounds-zonemap
2 parents 119fe60 + 80d4c7e commit 322e91d

31 files changed

Lines changed: 2805 additions & 36 deletions

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DerivePointerAlignment: false
2525
IncludeBlocks: Regroup
2626
InsertBraces: true
2727
Language: Cpp
28-
NamespaceIndentation: Inner
28+
NamespaceIndentation: None
2929
PointerAlignment: Right
3030
SpaceBeforeCpp11BracedList: true
3131
SpaceBeforeCtorInitializerColon: true

.github/workflows/ci.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ jobs:
355355
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
356356
- name: C/C++ Lint - clang-format
357357
run: |
358-
git ls-files vortex-cuda vortex-duckdb vortex-ffi \
358+
git ls-files lang/cpp vortex-cuda vortex-duckdb vortex-ffi \
359359
| grep -E '\.(cpp|hpp|cu|cuh|h)$' \
360360
| grep -v 'arrow/reference/arrow_c_device\.h$' \
361361
| grep -v 'kernels/src/bit_unpack_.*\.cu$' \
@@ -522,6 +522,40 @@ jobs:
522522
with:
523523
command: check ${{ matrix.checks }}
524524

525+
cxx-api:
526+
name: "C++ API"
527+
timeout-minutes: 5
528+
runs-on: >-
529+
${{ github.repository == 'vortex-data/vortex'
530+
&& format('runs-on={0}/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=cxx-build', github.run_id)
531+
|| 'ubuntu-latest' }}
532+
steps:
533+
- uses: runs-on/action@v2
534+
if: github.repository == 'vortex-data/vortex'
535+
with:
536+
sccache: s3
537+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
538+
- uses: ./.github/actions/setup-prebuild
539+
with:
540+
enable-sccache: "true"
541+
- name: Install Rust nightly toolchain
542+
run: |
543+
rustup toolchain install $NIGHTLY_TOOLCHAIN
544+
rustup component add --toolchain $NIGHTLY_TOOLCHAIN rust-src rustfmt clippy llvm-tools-preview
545+
- name: Build FFI library (asan)
546+
run: |
547+
RUSTFLAGS="-A warnings -Cunsafe-allow-abi-mismatch=sanitizer \
548+
-C debuginfo=2 -C opt-level=0 -C strip=none -Zexternal-clangrt \
549+
-Zsanitizer=address,leak" \
550+
cargo +$NIGHTLY_TOOLCHAIN build --locked --no-default-features \
551+
--target x86_64-unknown-linux-gnu -Zbuild-std \
552+
-p vortex-ffi
553+
- name: Build C++ library (asan)
554+
run: |
555+
mkdir -p build
556+
cmake -S lang/cpp -B build -DSANITIZER=asan -DTARGET_TRIPLE="x86_64-unknown-linux-gnu"
557+
cmake --build build --parallel $(nproc)
558+
525559
sqllogic-test:
526560
name: "SQL logic tests"
527561
needs: duckdb-ready

docs/Doxyfile.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Doxygen configuration for Vortex C++ API documentation.
2+
# XML output is consumed by Sphinx via the Breathe extension.
3+
4+
PROJECT_NAME = "Vortex C++"
5+
OUTPUT_DIRECTORY = _build/doxygen-cpp
6+
7+
# Input sources
8+
INPUT = ../lang/cpp/include/vortex
9+
FILE_PATTERNS = *.hpp
10+
RECURSIVE = NO
11+
12+
# We only care about XML output for Breathe
13+
GENERATE_XML = YES
14+
GENERATE_HTML = NO
15+
GENERATE_LATEX = NO
16+
XML_PROGRAMLISTING = YES
17+
18+
# Extract everything, even if not fully documented yet
19+
EXTRACT_ALL = YES
20+
EXTRACT_PRIVATE = NO
21+
EXTRACT_STATIC = YES
22+
23+
# Preprocessing — resolve includes but don't expand macros
24+
ENABLE_PREPROCESSING = YES
25+
MACRO_EXPANSION = NO
26+
27+
# Suppress warnings about undocumented members (WIP API)
28+
WARN_IF_UNDOCUMENTED = NO

docs/api/cpp/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Source code for this example is `writer.cpp
187187
Expression age_gt_10 = expr::gt(expr::col("age"), expr::lit<uint8_t>(10));
188188
Array validity_array = array.apply(age_gt_10);
189189
190-
const Validity validity {ValidityType::Array, validity_array};
190+
const Validity validity = Validity::from_array(validity_array);
191191
Array array2 = make_struct({
192192
{"age", age},
193193
{"height", Array::primitive<uint16_t>(height_buffer, validity)},

docs/conf.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -125,33 +125,6 @@
125125
breathe_projects = {"vortex-cpp": _doxygen_xml_dir}
126126
breathe_default_project = "vortex-cpp"
127127

128-
# C++ types from cxx bridge and standard library that Sphinx cannot resolve.
129-
nitpick_ignore += [
130-
("cpp:identifier", t)
131-
for t in [
132-
"vortex",
133-
"rust",
134-
"ffi",
135-
"uint8_t",
136-
"uint16_t",
137-
"uint32_t",
138-
"uint64_t",
139-
"int8_t",
140-
"int16_t",
141-
"int32_t",
142-
"int64_t",
143-
"size_t",
144-
"std::size_t",
145-
]
146-
]
147-
nitpick_ignore_regex = [
148-
# cxx bridge internals that will never be resolvable in Sphinx.
149-
(r"cpp:identifier", r"rust::.*"),
150-
(r"cpp:identifier", r"ffi::.*"),
151-
# Doxygen file-level labels (e.g. "dtype_8hpp") that we don't generate pages for.
152-
(r"ref", r".*_8hpp"),
153-
]
154-
155128
# -- Options for hawkmoth C API gen ----------------------------
156129

157130
hawkmoth_root = str(git_root / "vortex-ffi/cinclude")

encodings/experimental/onpair/src/compress.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ use crate::OnPair;
2727
use crate::OnPairArray;
2828

2929
/// Default OnPair training configuration: 12-bit codes ("dict-12").
30-
pub const DEFAULT_DICT12_CONFIG: Config = onpair::DEFAULT_CONFIG;
30+
pub const DEFAULT_DICT12_CONFIG: Config = Config {
31+
seed: Some(42),
32+
..onpair::DEFAULT_CONFIG
33+
};
3134

3235
fn onpair_compress_varbinview<O>(
3336
array: VarBinViewArray,

lang/cpp/CMakeLists.txt

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
cmake_minimum_required(VERSION 3.10)
5+
project(VortexCXX
6+
VERSION 0.0.1
7+
LANGUAGES CXX)
8+
9+
include(FetchContent)
10+
11+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
12+
set(CMAKE_CXX_STANDARD 20)
13+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14+
15+
find_program(SCCACHE_PROGRAM sccache)
16+
if (SCCACHE_PROGRAM)
17+
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
18+
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PROGRAM}")
19+
message(STATUS "Sccache found: ${SCCACHE_PROGRAM}")
20+
else ()
21+
message(STATUS "Sccache not found")
22+
endif ()
23+
24+
set(SANITIZER "" CACHE STRING "Build with sanitizers")
25+
set(TARGET_TRIPLE "" CACHE STRING "Rust target triple for FFI library")
26+
set(RUST_BUILD_PROFILE "" CACHE STRING "Cargo profile name for Rust FFI library")
27+
28+
if (NOT CMAKE_BUILD_TYPE)
29+
set(CMAKE_BUILD_TYPE Debug)
30+
endif()
31+
32+
if (NOT SANITIZER STREQUAL "")
33+
message(NOTICE "Sanitizer: ${SANITIZER}")
34+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
35+
message(FATAL_ERROR "Only debug build is supported for sanitizer builds")
36+
endif()
37+
38+
if (SANITIZER STREQUAL "asan")
39+
set(SANITIZER_FLAGS "-fsanitize=address,undefined,leak")
40+
elseif (SANITIZER STREQUAL "tsan")
41+
set(SANITIZER_FLAGS "-fsanitize=thread")
42+
else()
43+
message(FATAL_ERROR "Unknown sanitizer ${SANITIZER}")
44+
endif()
45+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
46+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
47+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
48+
endif()
49+
50+
if (RUST_BUILD_PROFILE STREQUAL "")
51+
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
52+
set(RUST_BUILD_PROFILE "release_debug")
53+
else()
54+
string(TOLOWER "${CMAKE_BUILD_TYPE}" RUST_BUILD_PROFILE)
55+
endif()
56+
endif()
57+
58+
set(VORTEX_FFI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../vortex-ffi")
59+
set(VORTEX_FFI_LIB_DIR "${VORTEX_FFI_DIR}/../target/${TARGET_TRIPLE}/${RUST_BUILD_PROFILE}")
60+
set(VORTEX_FFI_HEADERS "${VORTEX_FFI_DIR}/cinclude")
61+
62+
if(APPLE)
63+
set(VORTEX_FFI_STATIC "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.a")
64+
set(VORTEX_FFI_SHARED "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.dylib")
65+
elseif(WIN32)
66+
set(VORTEX_FFI_STATIC "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.lib")
67+
set(VORTEX_FFI_SHARED "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.dll")
68+
else()
69+
set(VORTEX_FFI_STATIC "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.a")
70+
set(VORTEX_FFI_SHARED "${VORTEX_FFI_LIB_DIR}/libvortex_ffi.so")
71+
endif()
72+
73+
if(NOT EXISTS "${VORTEX_FFI_STATIC}")
74+
message(FATAL_ERROR
75+
"vortex-ffi static library not found at ${VORTEX_FFI_STATIC}. "
76+
"Run: cargo build --profile <profile> -p vortex-ffi")
77+
endif()
78+
79+
add_library(vortex_ffi STATIC IMPORTED)
80+
set_target_properties(vortex_ffi PROPERTIES
81+
IMPORTED_LOCATION "${VORTEX_FFI_STATIC}"
82+
INTERFACE_INCLUDE_DIRECTORIES "${VORTEX_FFI_HEADERS}")
83+
84+
if(EXISTS "${VORTEX_FFI_SHARED}")
85+
add_library(vortex_ffi_shared SHARED IMPORTED)
86+
set_target_properties(vortex_ffi_shared PROPERTIES
87+
IMPORTED_LOCATION "${VORTEX_FFI_SHARED}"
88+
INTERFACE_INCLUDE_DIRECTORIES "${VORTEX_FFI_HEADERS}"
89+
INTERFACE_LINK_OPTIONS "LINKER:-rpath,${VORTEX_FFI_LIB_DIR}")
90+
endif()
91+
92+
file(GLOB VORTEX_CXX_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
93+
add_library(vortex_cxx STATIC ${VORTEX_CXX_SOURCES})
94+
target_include_directories(vortex_cxx PUBLIC
95+
${CMAKE_CURRENT_SOURCE_DIR}
96+
${CMAKE_CURRENT_SOURCE_DIR}/include
97+
${CMAKE_CURRENT_SOURCE_DIR}/../vortex-ffi/cinclude
98+
)
99+
target_link_libraries(vortex_cxx PUBLIC vortex_ffi)
100+
add_library(vortex::cxx ALIAS vortex_cxx)
101+
target_compile_features(vortex_cxx PUBLIC cxx_std_20)
102+
103+
set(APPLE_LINK_FLAGS "-framework CoreFoundation -framework Security")
104+
105+
if(APPLE)
106+
target_link_libraries(vortex_cxx PRIVATE ${APPLE_LINK_FLAGS})
107+
endif()
108+
109+
if(TARGET vortex_ffi_shared)
110+
add_library(vortex_cxx_shared SHARED ${VORTEX_CXX_SOURCES})
111+
set_target_properties(vortex_cxx_shared PROPERTIES POSITION_INDEPENDENT_CODE ON)
112+
target_include_directories(vortex_cxx_shared PUBLIC
113+
${CMAKE_CURRENT_SOURCE_DIR}
114+
${CMAKE_CURRENT_SOURCE_DIR}/include
115+
${CMAKE_CURRENT_SOURCE_DIR}/../vortex-ffi/cinclude
116+
)
117+
target_link_libraries(vortex_cxx_shared PUBLIC vortex_ffi_shared)
118+
add_library(vortex::cxx_shared ALIAS vortex_cxx_shared)
119+
target_compile_features(vortex_cxx_shared PUBLIC cxx_std_20)
120+
121+
if(APPLE)
122+
target_link_libraries(vortex_cxx_shared PRIVATE ${APPLE_LINK_FLAGS})
123+
endif()
124+
endif()

lang/cpp/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Vortex C++ bindings
2+
3+
For a usage guide, see docs/api/cpp/index.rst.
4+
5+
## Requirements
6+
7+
- CMake 3.10+
8+
- C++20 compiler (C++23 compiler for tests).
9+
- Rust toolchain for building `vortex-ffi`.
10+
11+
## Build
12+
13+
```sh
14+
cargo build --release -p vortex-ffi
15+
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
16+
cmake --build build -j
17+
```
18+
19+
This will generate `libvortex_cxx` shared and static libraries.
20+
You can use `vortex_cxx` and `vortex_cxx_shared` CMake targets.
21+
22+
## Test
23+
24+
```sh
25+
cargo build --release -p vortex-ffi
26+
cmake -Bbuild -DBUILD_TESTS=ON
27+
cmake --build build -j
28+
ctest --test-dir build -j "$(nproc)"
29+
```
30+
31+
## Run examples
32+
33+
```sh
34+
cmake -Bbuild -DBUILD_EXAMPLES=ON
35+
cmake --build build -j
36+
./build/examples/hello-vortex
37+
```

0 commit comments

Comments
 (0)