Skip to content

Commit 823b350

Browse files
authored
feat(index): introduce Lumina vector index and enable Lucene builds (#151)
1 parent f7e5751 commit 823b350

19 files changed

Lines changed: 1991 additions & 17 deletions

CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ option(PAIMON_ENABLE_AVRO "Whether to enable avro file format" ON)
5454
option(PAIMON_ENABLE_ORC "Whether to enable orc file format" ON)
5555
option(PAIMON_ENABLE_JINDO "Whether to enable jindo file system" OFF)
5656
option(PAIMON_ENABLE_LUCENE "Whether to enable lucene index" OFF)
57-
if(PAIMON_ENABLE_LUCENE)
58-
message(FATAL_ERROR "PAIMON_ENABLE_LUCENE is temporarily disabled. Please configure with -DPAIMON_ENABLE_LUCENE=OFF."
59-
)
60-
endif()
6157

6258
if(PAIMON_ENABLE_ORC)
6359
add_definitions(-DPAIMON_ENABLE_ORC)
@@ -302,12 +298,6 @@ endif()
302298
303299
list(APPEND PAIMON_LINK_LIBS ${CMAKE_DL_LIBS})
304300
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()
311301
312302
if(PAIMON_ENABLE_LUCENE)
313303
set(PAIMON_DICT_DEST "share/paimon/dict")
@@ -341,10 +331,6 @@ if(PAIMON_ENABLE_LANCE)
341331
include_directories("${CMAKE_SOURCE_DIR}/third_party/lance")
342332
endif()
343333
344-
if(PAIMON_ENABLE_LUMINA)
345-
include_directories("${CMAKE_SOURCE_DIR}/third_party/lumina/include")
346-
endif()
347-
348334
include_directories(SYSTEM ${ARROW_INCLUDE_DIR})
349335
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
350336

ci/scripts/build_paimon.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ 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"
43-
"-DPAIMON_ENABLE_LUCENE=OFF"
48+
"-DPAIMON_ENABLE_LUMINA=${ENABLE_LUMINA}"
49+
"-DPAIMON_ENABLE_LUCENE=ON"
4450
)
4551

4652
if [[ "${enable_sanitizer}" == "true" ]]; then

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,26 @@ 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+
294+
if(DEFINED ENV{PAIMON_BOOST_URL})
295+
set(BOOST_SOURCE_URL "$ENV{PAIMON_BOOST_URL}")
296+
elseif(EXISTS "${THIRDPARTY_DIR}/${PAIMON_BOOST_PKG_NAME}")
297+
set_urls(BOOST_SOURCE_URL "${THIRDPARTY_DIR}/${PAIMON_BOOST_PKG_NAME}")
298+
else()
299+
set_urls(BOOST_SOURCE_URL
300+
"https://paimon-cpp.oss-cn-beijing.aliyuncs.com/thirdparty/boost/${PAIMON_BOOST_PKG_NAME}"
301+
)
302+
endif()
303+
284304
if(APPLE)
285305
set(JINDOSDK_C_DYNAMIC_LIB_NAME "jindosdk_c.${PAIMON_JINDOSDK_C_BUILD_VERSION}")
286306
set(JINDOSDK_C_DYNAMIC_LIB_FILE "lib${JINDOSDK_C_DYNAMIC_LIB_NAME}.dylib")
@@ -938,7 +958,7 @@ macro(build_boost)
938958
endif()
939959

940960
externalproject_add(boost_ep
941-
URL "${THIRDPARTY_DIR}/boost/${PAIMON_BOOST_PKG_NAME}"
961+
URL ${BOOST_SOURCE_URL}
942962
URL_HASH "SHA256=${PAIMON_BOOST_BUILD_SHA256_CHECKSUM}"
943963
CONFIGURE_COMMAND ${BOOST_PREFIX}/src/boost_ep/bootstrap.sh
944964
--with-libraries=date_time,filesystem,iostreams,regex,system,thread,chrono,atomic
@@ -1196,6 +1216,42 @@ macro(build_jindosdk_c)
11961216

11971217
endmacro()
11981218

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

@@ -1817,6 +1873,9 @@ if(PAIMON_ENABLE_JINDO)
18171873
build_jindosdk_c()
18181874
build_jindosdk_nextarch()
18191875
endif()
1876+
if(PAIMON_ENABLE_LUMINA)
1877+
build_lumina()
1878+
endif()
18201879
if(PAIMON_ENABLE_LUCENE)
18211880
build_boost()
18221881
build_lucene()

docs/source/build_system.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ 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``
95+
- ``paimon_lucene_index_shared`` / ``paimon_lucene_index_static``
9496

9597
.. note::
9698

docs/source/building.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ 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.
128+
* ``-DPAIMON_ENABLE_LUCENE=ON``: Support for Lucene full-text search indexes
127129

128130
Third-party dependency source
129131
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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)