Skip to content

Commit ec8249c

Browse files
authored
Merge branch 'main' into clean_metric
2 parents e531ad0 + 17ab0c3 commit ec8249c

165 files changed

Lines changed: 4660 additions & 1478 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.

CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,22 @@ if(PAIMON_ENABLE_LUMINA)
290290
DESTINATION ${CMAKE_INSTALL_LIBDIR})
291291
endif()
292292
293+
if(PAIMON_ENABLE_LUCENE)
294+
set(PAIMON_DICT_DEST "share/paimon/dict")
295+
296+
install(DIRECTORY ${JIEBA_DICT_DIR}/
297+
DESTINATION ${PAIMON_DICT_DEST}
298+
FILES_MATCHING
299+
PATTERN "jieba.dict.utf8"
300+
PATTERN "hmm_model.utf8"
301+
PATTERN "idf.utf8"
302+
PATTERN "stop_words.utf8"
303+
PATTERN "user.dict.utf8"
304+
PATTERN "pos_dict"
305+
PATTERN ".git*" EXCLUDE
306+
PATTERN "*.md" EXCLUDE)
307+
endif()
308+
293309
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
294310
DESTINATION "include"
295311
FILES_MATCHING
@@ -389,7 +405,6 @@ if(PAIMON_BUILD_TESTS)
389405
list(APPEND TEST_STATIC_LINK_LIBS paimon_lucene_index_shared)
390406
list(APPEND TEST_STATIC_LINK_LIBS "-Wl,--as-needed")
391407
endif()
392-
393408
endif()
394409
395410
include(CMakePackageConfigHelpers)

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ This product includes code from Apache Iceberg C++.
266266
* Avro direct decoder/encoder:
267267
* src/paimon/format/avro/avro_direct_decoder.cpp
268268
* src/paimon/format/avro/avro_direct_decoder.h
269+
* src/paimon/format/avro/avro_direct_encoder.cpp
270+
* src/paimon/format/avro/avro_direct_encoder.h
269271

270272
Copyright: 2024-2025 The Apache Software Foundation.
271273
Home page: https://iceberg.apache.org/

cmake_modules/DefineOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
9292
define_option_string(PAIMON_CXXFLAGS "Compiler flags to append when compiling Paimon"
9393
"")
9494

95-
define_option(PAIMON_BUILD_STATIC "Build static libraries" OFF)
95+
define_option(PAIMON_BUILD_STATIC "Build static libraries" ON)
9696

9797
define_option(PAIMON_BUILD_SHARED "Build shared libraries" ON)
9898
#----------------------------------------------------------------------

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ macro(build_lucene)
322322
set(LUCENE_INCLUDE_DIR "${LUCENE_PREFIX}/include")
323323
# The include directory must exist before it is referenced by a target.
324324
file(MAKE_DIRECTORY "${LUCENE_INCLUDE_DIR}")
325-
include_directories(SYSTEM ${LUCENE_INCLUDE_DIR} ${BOOST_INCLUDE_DIR}
326-
${BOOST_EXTRA_INCLUDE_DIR})
325+
include_directories(SYSTEM ${LUCENE_INCLUDE_DIR} ${BOOST_INCLUDE_DIR})
327326
add_library(lucene INTERFACE IMPORTED)
328327
target_include_directories(lucene SYSTEM INTERFACE "${LUCENE_INCLUDE_DIR}")
329328
target_compile_options(lucene INTERFACE -pthread)
@@ -343,6 +342,43 @@ macro(build_lucene)
343342
add_dependencies(lucene lucene_ep)
344343
endmacro()
345344

345+
macro(build_jieba)
346+
message(STATUS "Building jieba from source")
347+
set(JIEBA_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/jieba_ep-prefix")
348+
set(JIEBA_INSTALL "${CMAKE_CURRENT_BINARY_DIR}/jieba_ep-install")
349+
set(JIEBA_INCLUDE_DIR "${JIEBA_INSTALL}/include")
350+
set(JIEBA_DICT_DIR "${JIEBA_INSTALL}/dict")
351+
file(MAKE_DIRECTORY ${JIEBA_INCLUDE_DIR})
352+
file(MAKE_DIRECTORY ${JIEBA_DICT_DIR})
353+
354+
set(JIEBA_CMAKE_ARGS
355+
${EP_COMMON_CMAKE_ARGS} "-DENABLE_TEST=OFF" "-DCPPJIEBA_TOP_LEVEL_PROJECT=OFF"
356+
"-DCMAKE_INSTALL_PREFIX=${JIEBA_INSTALL}")
357+
358+
set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/jieba.diff")
359+
externalproject_add(jieba_ep
360+
${EP_COMMON_OPTIONS}
361+
GIT_REPOSITORY https://github.com/yanyiwu/cppjieba.git
362+
GIT_TAG ${PAIMON_JIEBA_BUILD_VERSION}
363+
GIT_SHALLOW FALSE
364+
GIT_PROGRESS TRUE
365+
GIT_SUBMODULES_RECURSE TRUE
366+
CMAKE_ARGS ${JIEBA_CMAKE_ARGS}
367+
LOG_PATCH ON
368+
PATCH_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> bash -c
369+
"[ -f .patched ] && echo '<SOURCE_DIR> patch already applied, ignore...' || patch -s -N -p1 -i '${PATCH_FILE}' && touch .patched"
370+
INSTALL_COMMAND bash -c
371+
"cp -r ${JIEBA_PREFIX}/src/jieba_ep/include/* ${JIEBA_INSTALL}/include/ && cp -r ${JIEBA_PREFIX}/src/jieba_ep/dict/* ${JIEBA_INSTALL}/dict/ && cp -r ${JIEBA_PREFIX}/src/jieba_ep/deps/limonp/include/* ${JIEBA_INSTALL}/include/"
372+
)
373+
374+
# The include directory must exist before it is referenced by a target.
375+
include_directories(SYSTEM ${JIEBA_INCLUDE_DIR} ${JIEBA_DICT_DIR})
376+
add_library(jieba INTERFACE IMPORTED)
377+
target_include_directories(jieba SYSTEM
378+
INTERFACE "${JIEBA_INCLUDE_DIR} ${JIEBA_DICT_DIR}")
379+
add_dependencies(jieba jieba_ep)
380+
endmacro()
381+
346382
macro(build_rapidjson)
347383
message(STATUS "Building RapidJSON from source")
348384
set(RAPIDJSON_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/rapidjson_ep-install")
@@ -1272,4 +1308,5 @@ endif()
12721308
if(PAIMON_ENABLE_LUCENE)
12731309
build_boost()
12741310
build_lucene()
1311+
build_jieba()
12751312
endif()

cmake_modules/jieba.diff

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/include/cppjieba/KeywordExtractor.hpp b/include/cppjieba/KeywordExtractor.hpp
2+
index 24b2c40..c7c6a94 100644
3+
--- a/include/cppjieba/KeywordExtractor.hpp
4+
+++ b/include/cppjieba/KeywordExtractor.hpp
5+
@@ -89,6 +89,11 @@ class KeywordExtractor {
6+
std::partial_sort(keywords.begin(), keywords.begin() + topN, keywords.end(), Compare);
7+
keywords.resize(topN);
8+
}
9+
+
10+
+ const std::unordered_set<std::string>& GetStopWords() const {
11+
+ return stopWords_;
12+
+ }
13+
+
14+
private:
15+
void LoadIdfDict(const std::string& idfPath) {
16+
std::ifstream ifs(idfPath.c_str());

include/paimon/defs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct PAIMON_EXPORT Options {
130130
static const char MANIFEST_TARGET_FILE_SIZE[];
131131

132132
/// "manifest.format" - Specify the message format of manifest files.
133-
/// Default value is orc.
133+
/// Default value is avro.
134134
static const char MANIFEST_FORMAT[];
135135

136136
/// "manifest.compression" - File compression for manifest, default value is zstd.
@@ -287,6 +287,8 @@ struct PAIMON_EXPORT Options {
287287
/// "global-index.external-path" - Global index root directory, if not set, the global index
288288
/// files will be stored under the index directory.
289289
static const char GLOBAL_INDEX_EXTERNAL_PATH[];
290+
/// "scan.tag-name" - Optional tag name used in case of "from-snapshot" scan mode.
291+
static const char SCAN_TAG_NAME[];
290292
};
291293

292294
static constexpr int64_t BATCH_WRITE_COMMIT_IDENTIFIER = std::numeric_limits<int64_t>::max();

include/paimon/file_index/file_index_reader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class PAIMON_EXPORT FileIndexReader : public FunctionVisitor<std::shared_ptr<Fil
6060
Result<std::shared_ptr<FileIndexResult>> VisitEndsWith(const Literal& suffix) override;
6161

6262
Result<std::shared_ptr<FileIndexResult>> VisitContains(const Literal& literal) override;
63+
64+
Result<std::shared_ptr<FileIndexResult>> VisitLike(const Literal& literal) override;
6365
};
6466

6567
} // namespace paimon

include/paimon/predicate/function_visitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ class PAIMON_EXPORT FunctionVisitor {
7171

7272
/// Evaluates whether string values contain the given substring.
7373
virtual Result<T> VisitContains(const Literal& literal) = 0;
74+
75+
/// Evaluates whether string values like the given string.
76+
virtual Result<T> VisitLike(const Literal& literal) = 0;
7477
};
7578
} // namespace paimon

include/paimon/read_context.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "paimon/result.h"
2828
#include "paimon/type_fwd.h"
2929
#include "paimon/utils/read_ahead_cache.h"
30-
#include "paimon/utils/special_field_ids.h"
3130
#include "paimon/visibility.h"
3231

3332
namespace paimon {
@@ -54,8 +53,8 @@ class PAIMON_EXPORT ReadContext {
5453
const std::shared_ptr<Executor>& executor,
5554
const std::shared_ptr<FileSystem>& specific_file_system,
5655
const std::map<std::string, std::string>& fs_scheme_to_identifier_map,
57-
const std::map<std::string, std::string>& options, bool enable_prefetch_cache,
58-
const CacheConfig& cache_config);
56+
const std::map<std::string, std::string>& options,
57+
PrefetchCacheMode prefetch_cache_mode, const CacheConfig& cache_config);
5958
~ReadContext();
6059

6160
const std::string& GetPath() const {
@@ -117,8 +116,8 @@ class PAIMON_EXPORT ReadContext {
117116
return specific_file_system_;
118117
}
119118

120-
bool EnablePrefetchCache() const {
121-
return enable_prefetch_cache_;
119+
PrefetchCacheMode GetPrefetchCacheMode() const {
120+
return prefetch_cache_mode_;
122121
}
123122

124123
const CacheConfig& GetCacheConfig() const {
@@ -143,7 +142,7 @@ class PAIMON_EXPORT ReadContext {
143142
std::shared_ptr<FileSystem> specific_file_system_;
144143
std::map<std::string, std::string> fs_scheme_to_identifier_map_;
145144
std::map<std::string, std::string> options_;
146-
bool enable_prefetch_cache_;
145+
PrefetchCacheMode prefetch_cache_mode_;
147146
CacheConfig cache_config_;
148147
};
149148

@@ -179,9 +178,9 @@ class PAIMON_EXPORT ReadContextBuilder {
179178
/// @param read_field_ids Vector of field ids to read from the table.
180179
/// @return Reference to this builder for method chaining.
181180
/// @note Currently supports top-level field selection. Future versions may support
182-
/// nested field selection using ArrowSchema for more granular projection,
183-
/// If SetReadFieldIds() call and SetReadSchema() are natually are mutually
184-
/// exclusive. Calling both will ignore the read schema set by SetReadSchema().
181+
/// nested field selection using ArrowSchema for more granular projection.
182+
/// @note SetReadFieldIds() and SetReadSchema() are mutually exclusive.
183+
/// Calling both will ignore the read schema set by SetReadSchema().
185184
ReadContextBuilder& SetReadFieldIds(const std::vector<int32_t>& read_field_ids);
186185

187186
/// Set a configuration options map to set some option entries which are not defined in the
@@ -227,13 +226,13 @@ class PAIMON_EXPORT ReadContextBuilder {
227226
/// @return Reference to this builder for method chaining.
228227
ReadContextBuilder& EnablePrefetch(bool enabled);
229228

230-
/// Enable or disable prefetch cache for read operations.
229+
/// Set prefetch cache mode for read operations.
231230
///
232-
/// When enabled, a prefetch cache is used to prebuffer data ranges before they are needed,
231+
/// A prefetch cache is used to prebuffer data ranges before they are needed,
233232
/// which can improve read performance by reducing redundant I/O operations.
234-
/// @param enabled Whether to enable prefetch cache (default: true)
233+
/// @param mode (default: PrefetchCacheMode::ALWAYS)
235234
/// @return Reference to this builder for method chaining.
236-
ReadContextBuilder& EnablePrefetchCache(bool enabled);
235+
ReadContextBuilder& SetPrefetchCacheMode(PrefetchCacheMode mode);
237236

238237
/// Set the cache configuration for prefetch read operations.
239238
///

include/paimon/reader/file_batch_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PAIMON_EXPORT FileBatchReader : public BatchReader {
5050
virtual uint64_t GetPreviousBatchFirstRowNumber() const = 0;
5151

5252
/// Get the number of rows in the file.
53-
virtual uint64_t GetNumberOfRows() const = 0;
53+
virtual Result<uint64_t> GetNumberOfRows() const = 0;
5454

5555
/// Get whether or not support read precisely while bitmap pushed down.
5656
virtual bool SupportPreciseBitmapSelection() const = 0;

0 commit comments

Comments
 (0)