Skip to content

Commit aae05cc

Browse files
authored
feat(format): support Lance file format (#315)
1 parent 5024bb4 commit aae05cc

83 files changed

Lines changed: 9084 additions & 102 deletions

File tree

Some content is hidden

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

‎.codespell_ignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ VisitIn
99
NotIn
1010
Collet
1111
convertor
12+
inout

‎.github/workflows/build_and_test.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
build-and-test:
5454
name: ${{ matrix.name }}
5555
runs-on: ${{ matrix.runner || 'ubuntu-24.04' }}
56-
timeout-minutes: 120
56+
timeout-minutes: ${{ matrix.timeout_minutes || 120 }}
5757
strategy:
5858
fail-fast: false
5959
matrix:
@@ -69,6 +69,7 @@ jobs:
6969
cxx: g++-14
7070
- name: clang-debug-x86_64
7171
fetch_depth: '0' # fetch the PR target branch history for clang-tidy
72+
timeout_minutes: 180
7273
build_args: >-
7374
--check_clang_tidy
7475
--lint_git_target_commit "origin/${{ github.base_ref || github.event.repository.default_branch }}"
@@ -106,7 +107,7 @@ jobs:
106107
uses: ./.github/actions/setup-ccache
107108
with:
108109
cache-key-prefix: ccache-${{ matrix.name }}
109-
- name: Install Rust toolchain (Mosaic and tantivy-fts)
110+
- name: Install Rust and protobuf tools
110111
shell: bash
111112
run: ci/scripts/setup_rust.sh
112113
- name: Install build and debugging dependencies

‎.github/workflows/gcc8_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
ls -la
6161
- name: Checkout paimon-cpp
6262
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
63-
- name: Install Rust toolchain (Mosaic)
63+
- name: Install Rust and protobuf tools
6464
shell: bash
6565
run: ci/scripts/setup_rust.sh
6666
- name: Setup ccache

‎.github/workflows/release_candidate.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
name: source-archive
132132
path: release/ci
133133

134-
- name: Install Rust toolchain (Mosaic and tantivy-fts)
134+
- name: Install Rust and protobuf tools
135135
shell: bash
136136
run: ci/scripts/setup_rust.sh
137137

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ FlameGraph
6666
third_party/*.tar.gz
6767

6868
# Rust / Cargo build artifacts
69-
crates/tantivy_ffi/target/
69+
crates/*/target/

‎CMakeLists.txt‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ option(PAIMON_USE_CXX11_ABI "Use C++11 ABI" ON)
6161
option(PAIMON_ENABLE_AVRO "Whether to enable avro file format" ON)
6262
option(PAIMON_ENABLE_ORC "Whether to enable orc file format" ON)
6363
option(PAIMON_ENABLE_MOSAIC "Whether to enable mosaic file format (Rust FFI)" OFF)
64+
option(PAIMON_ENABLE_LANCE "Whether to enable lance file format (Rust FFI)" OFF)
6465
option(PAIMON_ENABLE_JINDO "Whether to enable jindo file system" OFF)
6566
option(PAIMON_ENABLE_OSS "Whether to enable OSS SDK v2 file system" OFF)
6667
option(PAIMON_ENABLE_S3 "Whether to enable S3 file system" OFF)
@@ -93,6 +94,9 @@ endif()
9394
if(PAIMON_ENABLE_MOSAIC)
9495
add_definitions(-DPAIMON_ENABLE_MOSAIC)
9596
endif()
97+
if(PAIMON_ENABLE_LANCE)
98+
add_definitions(-DPAIMON_ENABLE_LANCE)
99+
endif()
96100
if(PAIMON_ENABLE_JINDO)
97101
add_definitions(-DPAIMON_ENABLE_JINDO)
98102
endif()
@@ -328,13 +332,21 @@ set(PAIMON_SHARED_PRIVATE_LINK_LIBS ${PAIMON_STATIC_LINK_LIBS})
328332
add_subdirectory(third_party/roaring_bitmap EXCLUDE_FROM_ALL)
329333
add_subdirectory(third_party/xxhash EXCLUDE_FROM_ALL)
330334
331-
# ---- tantivy-fulltext Rust FFI via Corrosion-rs --------------------------------
332-
# Corrosion wraps the Cargo crate as a CMake target named `paimon_tantivy_ffi`.
333-
# `corrosion_experimental_cbindgen` runs cbindgen from CMake and writes the
334-
# header to a stable path; it also adds that path to the target's INTERFACE
335-
# include dirs so C++ consumers pick it up via target_link_libraries.
336-
if(PAIMON_ENABLE_TANTIVY)
335+
# ---- Rust FFI crates via Corrosion-rs -------------------------------------------
336+
if(PAIMON_ENABLE_LANCE OR PAIMON_ENABLE_TANTIVY)
337337
include(CorrosionFetch)
338+
endif()
339+
340+
if(PAIMON_ENABLE_LANCE)
341+
find_program(PAIMON_LANCE_PROTOC protoc REQUIRED)
342+
corrosion_import_crate(MANIFEST_PATH crates/lance_ffi/Cargo.toml CRATES
343+
paimon_lance_ffi)
344+
corrosion_experimental_cbindgen(TARGET paimon_lance_ffi HEADER_NAME
345+
paimon_lance_ffi.h)
346+
corrosion_set_env_vars(paimon_lance_ffi "PROTOC=${PAIMON_LANCE_PROTOC}")
347+
endif()
348+
349+
if(PAIMON_ENABLE_TANTIVY)
338350
corrosion_import_crate(MANIFEST_PATH crates/tantivy_ffi/Cargo.toml CRATES
339351
paimon_tantivy_ffi)
340352
corrosion_experimental_cbindgen(TARGET paimon_tantivy_ffi HEADER_NAME
@@ -403,6 +415,11 @@ if(PAIMON_BUILD_TESTS OR PAIMON_BUILD_BENCHMARKS)
403415
paimon_mosaic_file_format_static)
404416
endif()
405417
418+
if(PAIMON_ENABLE_LANCE)
419+
paimon_link_libraries_whole_archive(PAIMON_LANCE_FILE_FORMAT_STATIC_LINK_LIBS
420+
paimon_lance_file_format_static)
421+
endif()
422+
406423
if(PAIMON_ENABLE_ORC)
407424
paimon_link_libraries_whole_archive(PAIMON_ORC_FILE_FORMAT_STATIC_LINK_LIBS
408425
paimon_orc_file_format_static)
@@ -462,6 +479,14 @@ if(PAIMON_BUILD_TESTS)
462479
paimon_mosaic_file_format_static)
463480
endif()
464481
482+
if(PAIMON_ENABLE_LANCE)
483+
paimon_link_libraries_no_as_needed(TEST_PLUGIN_LINK_LIBS
484+
paimon_lance_file_format_shared)
485+
list(APPEND TEST_STATIC_LINK_LIBS ${TEST_PLUGIN_LINK_LIBS})
486+
paimon_link_libraries_whole_archive(PAIMON_LANCE_FILE_FORMAT_STATIC_LINK_LIBS
487+
paimon_lance_file_format_static)
488+
endif()
489+
465490
if(PAIMON_ENABLE_ORC)
466491
paimon_link_libraries_no_as_needed(TEST_PLUGIN_LINK_LIBS
467492
paimon_orc_file_format_shared)
@@ -554,6 +579,9 @@ add_subdirectory(src/paimon/format/avro)
554579
if(PAIMON_ENABLE_MOSAIC)
555580
add_subdirectory(src/paimon/format/mosaic)
556581
endif()
582+
if(PAIMON_ENABLE_LANCE)
583+
add_subdirectory(src/paimon/format/lance)
584+
endif()
557585
if(PAIMON_ENABLE_LUMINA)
558586
add_subdirectory(src/paimon/global_index/lumina)
559587
endif()

‎ci/scripts/build_paimon.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ pushd "${build_dir}"
129129

130130
ENABLE_LUMINA="ON"
131131
ENABLE_TANTIVY="ON"
132+
ENABLE_LANCE="ON"
132133
if [[ "${CC:-}" == *"gcc-8"* ]] || [[ "${CXX:-}" == *"g++-8"* ]]; then
133134
ENABLE_LUMINA="OFF"
134135
ENABLE_TANTIVY="OFF" # tantivy-fts (Rust FFI) is not built on the gcc-8 image.
135136
fi
136137
if [[ "${enable_tsan}" == "true" ]]; then
137138
ENABLE_TANTIVY="OFF" # Tantivy's Rust library is not TSAN-instrumented.
139+
ENABLE_LANCE="OFF" # Lance's Rust library is not TSAN-instrumented.
138140
fi
139141
# CI always builds natively, so the host architecture is the target architecture.
140142
host_arch=$(uname -m)
@@ -148,6 +150,7 @@ CMAKE_ARGS=(
148150
"-DCMAKE_BUILD_TYPE=${build_type}"
149151
"-DPAIMON_BUILD_TESTS=ON"
150152
"-DPAIMON_ENABLE_MOSAIC=ON"
153+
"-DPAIMON_ENABLE_LANCE=${ENABLE_LANCE}"
151154
"-DPAIMON_ENABLE_JINDO=ON"
152155
"-DPAIMON_ENABLE_OSS=ON"
153156
"-DPAIMON_ENABLE_S3=ON"

‎ci/scripts/setup_rust.sh‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18-
# Install the Rust toolchain used by the Mosaic and tantivy-fts FFI builds, plus cbindgen required
19-
# by tantivy-fts.
18+
# Install the Rust toolchain used by the Lance, Mosaic, and tantivy-fts FFI builds, plus
19+
# cbindgen required by Lance and tantivy-fts.
2020
#
2121
# The dev container (see .devcontainer/) already has these preinstalled;
2222
# this script is for the GitHub Actions runners and is called before ci/scripts/build_paimon.sh.
@@ -29,6 +29,7 @@ RUSTUP_VERSION=${RUSTUP_VERSION:-1.29.0}
2929
# 1.88.0 is the minimum required by transitive crates (e.g. time 0.3.47).
3030
RUST_VERSION=${RUST_VERSION:-1.88.0}
3131
CBINDGEN_VERSION=${CBINDGEN_VERSION:-0.29.2}
32+
PROTOC_VERSION=27.4
3233

3334
# Install rustup + default toolchain if cargo isn't on PATH yet.
3435
if ! command -v cargo >/dev/null 2>&1; then
@@ -44,6 +45,37 @@ rustup toolchain install "${RUST_VERSION}" --profile minimal
4445
rustup default "${RUST_VERSION}"
4546
rustup component add rustfmt clippy
4647

48+
# Lance's protobuf definitions use proto3 optional fields, which require protoc >= 3.12.
49+
if ! command -v protoc >/dev/null 2>&1 || \
50+
! protoc --experimental_allow_proto3_optional --version >/dev/null 2>&1; then
51+
case "$(uname -m)" in
52+
x86_64)
53+
protoc_arch="x86_64"
54+
protoc_sha256="20a977d023a47a7f27557aa144eb2c06baa6f623784e34d8a13d9abb6f6bc6c0"
55+
;;
56+
aarch64|arm64)
57+
protoc_arch="aarch_64"
58+
protoc_sha256="2399fa9e634880e70a8aa760b1b164ea0a8e8acac3bf541e732f9b3ade312cc9"
59+
;;
60+
*)
61+
echo "Unsupported architecture for protoc: $(uname -m)" >&2
62+
exit 1
63+
;;
64+
esac
65+
protoc_home="${HOME}/.local/protoc-${PROTOC_VERSION}"
66+
protoc_archive="/tmp/protoc-${PROTOC_VERSION}-${protoc_arch}.zip"
67+
if [[ ! -x "${protoc_home}/bin/protoc" ]]; then
68+
curl --proto '=https' --tlsv1.2 -fL \
69+
"https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${protoc_arch}.zip" \
70+
-o "${protoc_archive}"
71+
echo "${protoc_sha256} ${protoc_archive}" | sha256sum --check
72+
mkdir -p "${protoc_home}"
73+
unzip -oq "${protoc_archive}" -d "${protoc_home}"
74+
fi
75+
export PATH="${protoc_home}/bin:${PATH}"
76+
echo "${protoc_home}/bin" >> "${GITHUB_PATH:-/dev/null}" || true
77+
fi
78+
4779
# cbindgen is used by the crate's build.rs to emit the C header that the
4880
# C++ side includes. Corrosion will also run cbindgen at CMake configure
4981
# time; both paths need it available.
@@ -54,3 +86,4 @@ fi
5486
rustc --version
5587
cargo --version
5688
cbindgen --version
89+
protoc --version

0 commit comments

Comments
 (0)