Skip to content

Commit a4d6a2e

Browse files
committed
feat(index): introduce lumina vector index
1 parent f7e5751 commit a4d6a2e

19 files changed

Lines changed: 1976 additions & 10 deletions

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,6 @@ endif()
302302
303303
list(APPEND PAIMON_LINK_LIBS ${CMAKE_DL_LIBS})
304304
list(APPEND PAIMON_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS})
305-
if(PAIMON_ENABLE_LUMINA)
306-
add_subdirectory(third_party/lumina EXCLUDE_FROM_ALL)
307-
link_directories(third_party/lumina/lib)
308-
install(FILES ${PROJECT_SOURCE_DIR}/third_party/lumina/lib/liblumina.so
309-
DESTINATION ${CMAKE_INSTALL_LIBDIR})
310-
endif()
311305
312306
if(PAIMON_ENABLE_LUCENE)
313307
set(PAIMON_DICT_DEST "share/paimon/dict")
@@ -341,10 +335,6 @@ if(PAIMON_ENABLE_LANCE)
341335
include_directories("${CMAKE_SOURCE_DIR}/third_party/lance")
342336
endif()
343337
344-
if(PAIMON_ENABLE_LUMINA)
345-
include_directories("${CMAKE_SOURCE_DIR}/third_party/lumina/include")
346-
endif()
347-
348338
include_directories(SYSTEM ${ARROW_INCLUDE_DIR})
349339
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
350340

ci/scripts/build_paimon.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ fi
3535
mkdir ${build_dir}
3636
pushd ${build_dir}
3737

38+
ENABLE_LUMINA="ON"
39+
if [[ "${CC:-}" == *"gcc-8"* ]] || [[ "${CXX:-}" == *"g++-8"* ]]; then
40+
ENABLE_LUMINA="OFF"
41+
fi
42+
3843
CMAKE_ARGS=(
3944
"-G Ninja"
4045
"-DCMAKE_BUILD_TYPE=${build_type}"
4146
"-DPAIMON_BUILD_TESTS=ON"
4247
"-DPAIMON_ENABLE_JINDO=ON"
48+
"-DPAIMON_ENABLE_LUMINA=${ENABLE_LUMINA}"
4349
"-DPAIMON_ENABLE_LUCENE=OFF"
4450
)
4551

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,16 @@ else()
281281
endif()
282282
endif()
283283

284+
if(DEFINED ENV{PAIMON_LUMINA_URL})
285+
set(LUMINA_SOURCE_URL "$ENV{PAIMON_LUMINA_URL}")
286+
elseif(EXISTS "${THIRDPARTY_DIR}/${PAIMON_LUMINA_PKG_NAME}")
287+
set_urls(LUMINA_SOURCE_URL "${THIRDPARTY_DIR}/${PAIMON_LUMINA_PKG_NAME}")
288+
else()
289+
set_urls(LUMINA_SOURCE_URL
290+
"https://paimon-cpp.oss-cn-beijing.aliyuncs.com/thirdparty/lumina/lumina_release-${PAIMON_LUMINA_BUILD_VERSION}.tar.gz"
291+
)
292+
endif()
293+
284294
if(APPLE)
285295
set(JINDOSDK_C_DYNAMIC_LIB_NAME "jindosdk_c.${PAIMON_JINDOSDK_C_BUILD_VERSION}")
286296
set(JINDOSDK_C_DYNAMIC_LIB_FILE "lib${JINDOSDK_C_DYNAMIC_LIB_NAME}.dylib")
@@ -1196,6 +1206,42 @@ macro(build_jindosdk_c)
11961206

11971207
endmacro()
11981208

1209+
macro(build_lumina)
1210+
message(STATUS "Installing Lumina from precompiled package")
1211+
1212+
set(LUMINA_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lumina_ep-install")
1213+
set(LUMINA_INCLUDE_DIR "${LUMINA_PREFIX}/include")
1214+
set(LUMINA_LIB_DIR "${LUMINA_PREFIX}/lib")
1215+
set(LUMINA_DYNAMIC_LIB "${LUMINA_LIB_DIR}/liblumina.so")
1216+
1217+
externalproject_add(lumina_ep
1218+
URL ${LUMINA_SOURCE_URL}
1219+
URL_HASH "SHA256=${PAIMON_LUMINA_BUILD_SHA256_CHECKSUM}"
1220+
${THIRDPARTY_LOG_OPTIONS}
1221+
CONFIGURE_COMMAND ""
1222+
BUILD_COMMAND ""
1223+
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory
1224+
<SOURCE_DIR>/artifacts/cpp/linux-x86_64/install-root/usr/local/include
1225+
${LUMINA_INCLUDE_DIR}
1226+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
1227+
<SOURCE_DIR>/artifacts/cpp/linux-x86_64/install-root/usr/local/lib/liblumina.so
1228+
${LUMINA_DYNAMIC_LIB}
1229+
BUILD_BYPRODUCTS "${LUMINA_DYNAMIC_LIB}")
1230+
1231+
file(MAKE_DIRECTORY "${LUMINA_INCLUDE_DIR}")
1232+
file(MAKE_DIRECTORY "${LUMINA_LIB_DIR}")
1233+
1234+
add_library(lumina::interface SHARED IMPORTED GLOBAL)
1235+
set_target_properties(lumina::interface
1236+
PROPERTIES IMPORTED_LOCATION "${LUMINA_DYNAMIC_LIB}"
1237+
IMPORTED_NO_SONAME TRUE
1238+
INTERFACE_INCLUDE_DIRECTORIES
1239+
"${LUMINA_INCLUDE_DIR}")
1240+
add_dependencies(lumina::interface lumina_ep)
1241+
1242+
install(FILES "${LUMINA_DYNAMIC_LIB}" DESTINATION ${CMAKE_INSTALL_LIBDIR})
1243+
endmacro()
1244+
11991245
macro(build_jindosdk_nextarch)
12001246
message(STATUS "Building jindosdk-nextarch from local source")
12011247

@@ -1817,6 +1863,9 @@ if(PAIMON_ENABLE_JINDO)
18171863
build_jindosdk_c()
18181864
build_jindosdk_nextarch()
18191865
endif()
1866+
if(PAIMON_ENABLE_LUMINA)
1867+
build_lumina()
1868+
endif()
18201869
if(PAIMON_ENABLE_LUCENE)
18211870
build_boost()
18221871
build_lucene()

docs/source/build_system.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Paimon provides a set of built-in optional plugins that you can link to as neede
9191
- Index plugins:
9292

9393
- ``paimon_file_index_shared`` / ``paimon_file_index_static``
94+
- ``paimon_lumina_index_shared`` / ``paimon_lumina_index_static``
9495

9596
.. note::
9697

docs/source/building.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ boolean flags to ``cmake``.
124124
* ``-DPAIMON_ENABLE_ORC=ON``: Paimon integration with Apache ORC
125125
* ``-DPAIMON_ENABLE_AVRO=ON``: Apache Avro libraries and Paimon integration
126126
* ``-DPAIMON_ENABLE_JINDO=ON``: Support for Alibaba Jindo filesystems
127+
* ``-DPAIMON_ENABLE_LUMINA=ON``: Support for the Lumina vector index.
127128

128129
Third-party dependency source
129130
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/source/user_guide/global_index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Paimon supports multiple global index types:
2626
- **BTree Index**: An efficient index based on multi-level SST files for scalar column lookups.
2727
- **Range Bitmap Index**: A range bitmap index optimized for range predicates on ordered scalar columns. Extends the bitmap approach by encoding value ordering, enabling efficient less-than, greater-than, and range conditions.
2828
- **Lucene Index**: A full-text search index powered by Lucene++. Supports tokenized text search with multiple modes including match-all, match-any, phrase, prefix, and wildcard queries.
29+
- **Vector Index (Lumina)**: An approximate nearest neighbor (ANN) index powered by Lumina for vector similarity search with configurable distance metrics.
2930

3031
Global indexes work on top of Data Evolution tables. To use global indexes, your table must have:
3132

@@ -85,3 +86,10 @@ search modes including match-all, match-any, phrase, prefix, and wildcard querie
8586
- **Environment Variable**: ``PAIMON_JIEBA_DICT_DIR``
8687

8788
- **Description**: Specifies the directory containing Jieba dictionary files for Chinese text tokenization. At runtime, the system first checks this environment variable; if not set, it falls back to the compile-time ``JIEBA_TEST_DICT_DIR`` macro (only available in test builds). If neither is available, will fail with an error.
89+
90+
Vector Index (Lumina)
91+
---------------------
92+
93+
An approximate nearest neighbor (ANN) index powered by Lumina for vector similarity search.
94+
It supports high-dimensional vector search with configurable distance metrics and encoding strategies.
95+
For more configurations, refer to the ``docs/reference`` directory in the Lumina release package.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
if(PAIMON_ENABLE_LUMINA)
18+
set(PAIMON_LUMINA_INDEX lumina_global_index.cpp lumina_global_index_factory.cpp)
19+
20+
add_paimon_lib(paimon_lumina_index
21+
SOURCES
22+
${PAIMON_LUMINA_INDEX}
23+
DEPENDENCIES
24+
paimon_shared
25+
lumina::interface
26+
STATIC_LINK_LIBS
27+
arrow
28+
glog
29+
fmt
30+
dl
31+
Threads::Threads
32+
SHARED_LINK_LIBS
33+
lumina::interface
34+
paimon_shared
35+
SHARED_LINK_FLAGS
36+
${PAIMON_VERSION_SCRIPT_FLAGS})
37+
38+
if(PAIMON_BUILD_TESTS)
39+
add_paimon_test(lumina_index_test
40+
SOURCES
41+
lumina_api_test.cpp
42+
lumina_file_io_test.cpp
43+
lumina_global_index_test.cpp
44+
EXTRA_INCLUDES
45+
${LUMINA_INCLUDE_DIR}
46+
STATIC_LINK_LIBS
47+
paimon_shared
48+
test_utils_static
49+
"-Wl,--whole-archive"
50+
paimon_local_file_system_static
51+
paimon_lumina_index_static
52+
"-Wl,--no-whole-archive"
53+
lumina::interface
54+
${GTEST_LINK_TOOLCHAIN})
55+
endif()
56+
57+
endif()

0 commit comments

Comments
 (0)