Skip to content

Commit fc932c9

Browse files
authored
Storages: Deprecated libclara for normal build (#10325)
close #10324 Storages: Deprecated libclara for normal build * Add `ENABLE_CLARA` and disable it by default in normal build * Exclude the files under `dbms/src/Storages/DeltaMerge/Index/FullTextIndex` when `ENABLE_CLARA` is disabled Signed-off-by: JaySon-Huang <[email protected]>
1 parent 897842a commit fc932c9

Some content is hidden

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

44 files changed

+262
-31
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ include (cmake/utils.cmake)
4444

4545
option(ENABLE_PCH "Enable `Precompiled header`" OFF)
4646

47+
option(ENABLE_CLARA "Enable `Clara` library" OFF)
48+
4749
include (cmake/find_ccache.cmake)
4850

4951
# Write compile_commands.json
@@ -312,7 +314,9 @@ include (cmake/find_tipb.cmake)
312314
include (cmake/find_curl.cmake)
313315
include (cmake/find_prometheus.cmake)
314316
include (cmake/find_tiflash_proxy.cmake)
315-
include (cmake/find_libclara.cmake)
317+
if (ENABLE_CLARA)
318+
include (cmake/find_libclara.cmake)
319+
endif ()
316320
include (cmake/find_xxhash.cmake)
317321

318322
if (OS_LINUX AND ARCH_AMD64 AND TIFLASH_ENABLE_AVX512_SUPPORT)

dbms/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ target_link_libraries (dbms
225225
absl::synchronization
226226
tiflash_contrib::aws_s3
227227
tiflash_vector_search
228-
clara_shared
229228

230229
etcdpb
231230
tiflash_parsers
@@ -241,6 +240,10 @@ target_link_libraries (dbms
241240
kvstore
242241
)
243242

243+
if (ENABLE_CLARA)
244+
target_link_libraries(dbms clara_shared)
245+
endif ()
246+
244247
# always add GmSSL include dir to the include path for static analysis
245248
target_include_directories(dbms PRIVATE ${TiFlash_SOURCE_DIR}/contrib/GmSSL/include)
246249
if (USE_GM_SSL)
@@ -375,7 +378,7 @@ if (ENABLE_TESTS)
375378
DESTINATION ".")
376379
endif ()
377380

378-
if (USE_INTERNAL_LIBCLARA)
381+
if (ENABLE_CLARA AND USE_INTERNAL_LIBCLARA)
379382
install (TARGETS clara_shared
380383
COMPONENT tiflash-gtest
381384
DESTINATION ".")
@@ -384,7 +387,9 @@ if (ENABLE_TESTS)
384387
set_target_properties(gtests_dbms PROPERTIES BUILD_RPATH "$ORIGIN/")
385388
set_target_properties(gtests_dbms PROPERTIES INSTALL_RPATH "$ORIGIN/")
386389

387-
install (SCRIPT ${TiFlash_SOURCE_DIR}/libs/libclara-cmake/linux_post_install.cmake COMPONENT tiflash-gtest)
390+
if (ENABLE_CLARA)
391+
install (SCRIPT ${TiFlash_SOURCE_DIR}/libs/libclara-cmake/linux_post_install.cmake COMPONENT tiflash-gtest)
392+
endif ()
388393

389394
target_compile_options(gtests_dbms PRIVATE -Wno-unknown-pragmas -Wno-deprecated-copy)
390395
add_check(gtests_dbms)

dbms/src/Common/TiFlashBuildInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ String getEnabledFeatures()
146146
#if ENABLE_NEXT_GEN
147147
"next-gen",
148148
#endif
149+
150+
// Clara
151+
#if ENABLE_CLARA
152+
"clara",
153+
#endif
149154
};
150155
{
151156
auto f = DB::DM::VectorIndexHNSWSIMDFeatures::get();

dbms/src/Common/config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
#cmakedefine01 USE_GM_SSL
88
#cmakedefine01 USE_QPL
99
#cmakedefine01 ENABLE_NEXT_GEN
10+
#cmakedefine01 ENABLE_CLARA

dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <Common/Stopwatch.h>
1919
#include <Common/TiFlashException.h>
2020
#include <Common/TiFlashMetrics.h>
21+
#include <Common/config.h> // For ENABLE_CLARA
2122
#include <DataStreams/ExpressionBlockInputStream.h>
2223
#include <DataStreams/FilterBlockInputStream.h>
2324
#include <DataStreams/GeneratedColumnPlaceholderBlockInputStream.h>
@@ -41,7 +42,6 @@
4142
#include <Operators/NullSourceOp.h>
4243
#include <Operators/UnorderedSourceOp.h>
4344
#include <Parsers/makeDummyQuery.h>
44-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx.h>
4545
#include <Storages/DeltaMerge/Index/VectorIndex/Stream/Ctx.h>
4646
#include <Storages/DeltaMerge/Remote/DisaggSnapshot.h>
4747
#include <Storages/DeltaMerge/Remote/WNDisaggSnapshotManager.h>
@@ -62,6 +62,10 @@
6262
#include <kvproto/coprocessor.pb.h>
6363
#include <tipb/select.pb.h>
6464

65+
#if ENABLE_CLARA
66+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx.h>
67+
#endif
68+
6569
namespace DB
6670
{
6771
namespace FailPoints
@@ -1610,8 +1614,10 @@ std::pair<Names, std::vector<UInt8>> DAGStorageInterpreter::getColumnsForTableSc
16101614
name = MutSup::extra_table_id_column_name;
16111615
else if (cid == DM::VectorIndexStreamCtx::VIRTUAL_DISTANCE_CD.id)
16121616
name = DM::VectorIndexStreamCtx::VIRTUAL_DISTANCE_CD.name;
1617+
#if ENABLE_CLARA
16131618
else if (cid == DM::FullTextIndexStreamCtx::VIRTUAL_SCORE_CD.id)
16141619
name = DM::FullTextIndexStreamCtx::VIRTUAL_SCORE_CD.name;
1620+
#endif
16151621
else
16161622
name = storage_for_logical_table->getTableInfo().getColumnName(cid);
16171623
required_columns_tmp.emplace_back(std::move(name));

dbms/src/Server/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ if (OS_LINUX)
124124
DESTINATION ".")
125125
endif()
126126

127-
if (USE_INTERNAL_LIBCLARA)
127+
if (ENABLE_CLARA AND USE_INTERNAL_LIBCLARA)
128128
install (TARGETS clara_shared
129129
COMPONENT tiflash-release
130130
DESTINATION ".")
@@ -134,12 +134,14 @@ if (OS_LINUX)
134134
install (SCRIPT ${TiFlash_SOURCE_DIR}/cmake/tiflash_linux_post_install.cmake COMPONENT tiflash-release)
135135
endif()
136136
install (SCRIPT ${TiFlash_SOURCE_DIR}/contrib/tiflash-proxy-cmake/tiflash_proxy_linux_post_install.cmake COMPONENT tiflash-release)
137-
install (SCRIPT ${TiFlash_SOURCE_DIR}/libs/libclara-cmake/linux_post_install.cmake COMPONENT tiflash-release)
137+
if (ENABLE_CLARA)
138+
install (SCRIPT ${TiFlash_SOURCE_DIR}/libs/libclara-cmake/linux_post_install.cmake COMPONENT tiflash-release)
139+
endif()
138140
elseif(APPLE)
139141
# set build rpaths, so that executables can be directly called in build tree (easy to debug)
140142
set_target_properties(tiflash PROPERTIES BUILD_RPATH "@executable_path/;@executable_path/${TIFLASH_PROXY_LIB_RPATH}/")
141143
set_target_properties(tiflash PROPERTIES INSTALL_RPATH "@executable_path/")
142-
if (USE_INTERNAL_LIBCLARA)
144+
if (ENABLE_CLARA AND USE_INTERNAL_LIBCLARA)
143145
install (TARGETS clara_shared
144146
COMPONENT tiflash-release
145147
DESTINATION ".")

dbms/src/Storages/DeltaMerge/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ add_headers_and_sources(delta_merge ./Index/InvertedIndex)
3232
add_headers_and_sources(delta_merge ./Index/InvertedIndex/Reader)
3333
add_headers_and_sources(delta_merge ./Index/VectorIndex)
3434
add_headers_and_sources(delta_merge ./Index/VectorIndex/Stream)
35-
add_headers_and_sources(delta_merge ./Index/FullTextIndex)
36-
add_headers_and_sources(delta_merge ./Index/FullTextIndex/Stream)
35+
if (ENABLE_CLARA)
36+
add_headers_and_sources(delta_merge ./Index/FullTextIndex)
37+
add_headers_and_sources(delta_merge ./Index/FullTextIndex/Stream)
38+
endif ()
3739
add_headers_and_sources(delta_merge ./ReadThread)
3840
add_headers_and_sources(delta_merge ./Remote)
3941
add_headers_and_sources(delta_merge ./Remote/DataStore)

dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <Common/config.h> // For ENABLE_CLARA
1516
#include <Interpreters/Context.h>
1617
#include <Storages/DeltaMerge/File/DMFileBlockInputStream.h>
17-
#include <Storages/DeltaMerge/Index/FullTextIndex/Perf.h>
18-
#include <Storages/DeltaMerge/Index/FullTextIndex/Reader.h>
19-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/BruteScoreInputStream.h>
20-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx.h>
21-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/DMFileInputStream.h>
2218
#include <Storages/DeltaMerge/Index/VectorIndex/Perf.h>
2319
#include <Storages/DeltaMerge/Index/VectorIndex/Reader.h>
2420
#include <Storages/DeltaMerge/Index/VectorIndex/Stream/Ctx.h>
@@ -27,6 +23,13 @@
2723
#include <Storages/DeltaMerge/ReadThread/SegmentReader.h>
2824
#include <Storages/DeltaMerge/ScanContext.h>
2925

26+
#if ENABLE_CLARA
27+
#include <Storages/DeltaMerge/Index/FullTextIndex/Perf.h>
28+
#include <Storages/DeltaMerge/Index/FullTextIndex/Reader.h>
29+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/BruteScoreInputStream.h>
30+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx.h>
31+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/DMFileInputStream.h>
32+
#endif
3033
namespace DB::DM
3134
{
3235

@@ -145,10 +148,12 @@ SkippableBlockInputStreamPtr DMFileBlockInputStreamBuilder::build(
145148
const RowKeyRanges & rowkey_ranges,
146149
const ScanContextPtr & scan_context)
147150
{
151+
// Note: this file may not have index built
148152
{
149-
// Note: this file may not have index built
153+
#if ENABLE_CLARA
150154
if (fts_index_ctx)
151155
return buildForFullTextIndex(dmfile, read_columns, rowkey_ranges, scan_context);
156+
#endif
152157
if (vec_index_ctx)
153158
return buildForVectorIndex(dmfile, read_columns, rowkey_ranges, scan_context);
154159
}
@@ -241,6 +246,7 @@ SkippableBlockInputStreamPtr DMFileBlockInputStreamBuilder::buildForVectorIndex(
241246
std::move(rest_columns_reader));
242247
}
243248

249+
#if ENABLE_CLARA
244250
SkippableBlockInputStreamPtr DMFileBlockInputStreamBuilder::buildForFullTextIndex(
245251
const DMFilePtr & dmfile,
246252
const ColumnDefines & read_columns,
@@ -327,5 +333,6 @@ SkippableBlockInputStreamPtr DMFileBlockInputStreamBuilder::buildForFullTextInde
327333
dmfile,
328334
std::move(rest_columns_reader));
329335
}
336+
#endif
330337

331338
} // namespace DB::DM

dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515
#pragma once
1616

1717
#include <Common/Exception.h>
18+
#include <Common/config.h> // For ENABLE_CLARA
1819
#include <Interpreters/Context_fwd.h>
1920
#include <Interpreters/Settings.h>
2021
#include <Storages/DeltaMerge/DeltaMergeDefines.h>
2122
#include <Storages/DeltaMerge/File/ColumnCache.h>
2223
#include <Storages/DeltaMerge/File/ColumnCacheLongTerm_fwd.h>
2324
#include <Storages/DeltaMerge/File/DMFileReader.h>
24-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx_fwd.h>
2525
#include <Storages/DeltaMerge/Index/VectorIndex/Stream/Ctx_fwd.h>
2626
#include <Storages/DeltaMerge/RowKeyRange.h>
2727
#include <Storages/DeltaMerge/ScanContext_fwd.h>
2828
#include <Storages/DeltaMerge/SkippableBlockInputStream.h>
2929

30+
#if ENABLE_CLARA
31+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/Ctx_fwd.h>
32+
#endif
3033

3134
namespace DB::DM
3235
{
@@ -122,11 +125,13 @@ class DMFileBlockInputStreamBuilder
122125
return *this;
123126
}
124127

128+
#if ENABLE_CLARA
125129
DMFileBlockInputStreamBuilder & setFtsIndexQuery(const FullTextIndexStreamCtxPtr & ctx)
126130
{
127131
fts_index_ctx = ctx;
128132
return *this;
129133
}
134+
#endif
130135

131136
DMFileBlockInputStreamBuilder & setReadPacks(const IdSetPtr & read_packs_)
132137
{
@@ -201,12 +206,14 @@ class DMFileBlockInputStreamBuilder
201206
const RowKeyRanges & rowkey_ranges,
202207
const ScanContextPtr & scan_context);
203208

209+
#if ENABLE_CLARA
204210
/// The returned stream should be plugged into a FullTextIndexInputStream. Plug to somewhere else will not work.
205211
SkippableBlockInputStreamPtr buildForFullTextIndex(
206212
const DMFilePtr & dmfile,
207213
const ColumnDefines & read_columns,
208214
const RowKeyRanges & rowkey_ranges,
209215
const ScanContextPtr & scan_context);
216+
#endif
210217

211218
private:
212219
// These methods are called by the ctor
@@ -253,7 +260,9 @@ class DMFileBlockInputStreamBuilder
253260
/// If set, will *try* to build a VectorIndexDMFileInputStream
254261
/// instead of a normal DMFileBlockInputStream.
255262
VectorIndexStreamCtxPtr vec_index_ctx = nullptr;
263+
#if ENABLE_CLARA
256264
FullTextIndexStreamCtxPtr fts_index_ctx = nullptr;
265+
#endif
257266

258267
// Note: column_cache_long_term is currently only filled when performing Vector Search.
259268
ColumnCacheLongTermPtr column_cache_long_term = nullptr;

dbms/src/Storages/DeltaMerge/File/ReadBlockInfo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <Common/config.h> // For ENABLE_CLARA
1516
#include <Storages/DeltaMerge/File/ReadBlockInfo.h>
16-
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/IProvideFullTextIndex.h>
1717
#include <Storages/DeltaMerge/Index/VectorIndex/Stream/IProvideVectorIndex.h>
1818

1919
#include <span>
2020

21+
#if ENABLE_CLARA
22+
#include <Storages/DeltaMerge/Index/FullTextIndex/Stream/IProvideFullTextIndex.h>
23+
#endif
24+
2125
namespace DB::DM
2226
{
2327

@@ -140,11 +144,13 @@ template ReadBlockInfos ReadBlockInfo::createWithRowIDs<IProvideVectorIndex::Sea
140144
const DMFileMeta::PackStats & pack_stats,
141145
size_t rows_threshold_per_read);
142146

147+
#if ENABLE_CLARA
143148
template ReadBlockInfos ReadBlockInfo::createWithRowIDs<IProvideFullTextIndex::SearchResult>(
144149
std::span<IProvideFullTextIndex::SearchResult> row_ids,
145150
const std::vector<size_t> & pack_offset,
146151
const RSResults & pack_res,
147152
const DMFileMeta::PackStats & pack_stats,
148153
size_t rows_threshold_per_read);
154+
#endif
149155

150156
} // namespace DB::DM

0 commit comments

Comments
 (0)