Skip to content

Commit d124916

Browse files
committed
fix
1 parent a7157c2 commit d124916

7 files changed

Lines changed: 38 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ if(PAIMON_ENABLE_LUCENE)
303303
PATTERN "user.dict.utf8"
304304
PATTERN "pos_dict"
305305
PATTERN ".git*" EXCLUDE
306-
PATTERN "*.md" EXCLUDE)
306+
PATTERN "*.md" EXCLUDE)
307307
endif()
308308
309309
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/

cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,10 @@ macro(build_jieba)
352352
file(MAKE_DIRECTORY ${JIEBA_DICT_DIR})
353353

354354
set(JIEBA_CMAKE_ARGS
355-
${EP_COMMON_CMAKE_ARGS}
356-
"-DENABLE_TEST=OFF"
357-
"-DCPPJIEBA_TOP_LEVEL_PROJECT=OFF"
355+
${EP_COMMON_CMAKE_ARGS} "-DENABLE_TEST=OFF" "-DCPPJIEBA_TOP_LEVEL_PROJECT=OFF"
358356
"-DCMAKE_INSTALL_PREFIX=${JIEBA_INSTALL}")
359357

360-
set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/jieba.diff")
358+
set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/jieba.diff")
361359
externalproject_add(jieba_ep
362360
${EP_COMMON_OPTIONS}
363361
GIT_REPOSITORY https://github.com/yanyiwu/cppjieba.git
@@ -370,13 +368,14 @@ macro(build_jieba)
370368
PATCH_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> bash -c
371369
"[ -f .patched ] && echo '<SOURCE_DIR> patch already applied, ignore...' || patch -s -N -p1 -i '${PATCH_FILE}' && touch .patched"
372370
INSTALL_COMMAND bash -c
373-
"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/"
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/"
374372
)
375373

376374
# The include directory must exist before it is referenced by a target.
377375
include_directories(SYSTEM ${JIEBA_INCLUDE_DIR} ${JIEBA_DICT_DIR})
378376
add_library(jieba INTERFACE IMPORTED)
379-
target_include_directories(jieba SYSTEM INTERFACE "${JIEBA_INCLUDE_DIR} ${JIEBA_DICT_DIR}")
377+
target_include_directories(jieba SYSTEM
378+
INTERFACE "${JIEBA_INCLUDE_DIR} ${JIEBA_DICT_DIR}")
380379
add_dependencies(jieba jieba_ep)
381380
endmacro()
382381

cmake_modules/jieba.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ index 24b2c40..c7c6a94 100644
1010
+ const std::unordered_set<std::string>& GetStopWords() const {
1111
+ return stopWords_;
1212
+ }
13-
+
13+
+
1414
private:
1515
void LoadIdfDict(const std::string& idfPath) {
1616
std::ifstream ifs(idfPath.c_str());

src/paimon/global_index/lucene/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
# limitations under the License.
1414

1515
if(PAIMON_ENABLE_LUCENE)
16-
set(PAIMON_LUCENE lucene_global_index.cpp
17-
lucene_directory.cpp
18-
jieba_analyzer.cpp
19-
lucene_global_index_writer.cpp
20-
lucene_global_index_reader.cpp
21-
lucene_global_index_factory.cpp)
16+
set(PAIMON_LUCENE
17+
lucene_global_index.cpp
18+
lucene_directory.cpp
19+
jieba_analyzer.cpp
20+
lucene_global_index_writer.cpp
21+
lucene_global_index_reader.cpp
22+
lucene_global_index_factory.cpp)
2223

2324
add_paimon_lib(paimon_lucene_index
2425
SOURCES
@@ -61,7 +62,7 @@ if(PAIMON_ENABLE_LUCENE)
6162
"-Wl,--no-whole-archive"
6263
${GTEST_LINK_TOOLCHAIN})
6364

64-
target_compile_definitions(paimon-lucene-index-test PRIVATE
65-
JIEBA_TEST_DICT_DIR="${JIEBA_DICT_DIR}")
65+
target_compile_definitions(paimon-lucene-index-test
66+
PRIVATE JIEBA_TEST_DICT_DIR="${JIEBA_DICT_DIR}")
6667
endif()
6768
endif()

src/paimon/global_index/lucene/jieba_analyzer.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ JiebaTokenizerContext::JiebaTokenizerContext(const std::string& _tokenize_mode,
2929
jieba(_jieba) {}
3030

3131
JiebaTokenizer::JiebaTokenizer(const JiebaTokenizerContext& context, const Lucene::ReaderPtr& input)
32-
: Lucene::Tokenizer(), context_(context) {
33-
this->input = input;
32+
: Lucene::Tokenizer(input), context_(context) {
3433
term_att_ = addAttribute<Lucene::TermAttribute>();
3534
pos_att_ = addAttribute<Lucene::PositionIncrementAttribute>();
3635
buffer_ = static_cast<wchar_t*>(
37-
context_.pool->Malloc(context_.buffer_size * sizeof(wchar_t), /*aligment=*/8));
36+
context_.pool->Malloc(context_.buffer_size * sizeof(wchar_t), /*alignment=*/8));
3837
}
3938

4039
JiebaTokenizer::~JiebaTokenizer() {
4140
if (buffer_) {
4241
context_.pool->Free(reinterpret_cast<void*>(buffer_),
4342
context_.buffer_size * sizeof(wchar_t),
44-
/*aligment=*/8);
43+
/*alignment=*/8);
4544
buffer_ = nullptr;
4645
}
4746
}
@@ -98,7 +97,7 @@ void JiebaTokenizer::Normalize(const std::unordered_set<std::string>& stop_words
9897

9998
// to lower case
10099
bool is_alphanumeric = true;
101-
for (const unsigned char& c : term) {
100+
for (const auto& c : term) {
102101
if (!std::isalnum(c)) {
103102
is_alphanumeric = false;
104103
break;
@@ -113,6 +112,15 @@ void JiebaTokenizer::Normalize(const std::unordered_set<std::string>& stop_words
113112

114113
void JiebaTokenizer::reset() {
115114
Lucene::Tokenizer::reset();
115+
InnerReset();
116+
}
117+
118+
void JiebaTokenizer::reset(const Lucene::ReaderPtr& input) {
119+
Lucene::Tokenizer::reset(input);
120+
InnerReset();
121+
}
122+
123+
void JiebaTokenizer::InnerReset() {
116124
terms_.clear();
117125
normalized_terms_.clear();
118126
term_index_ = 0;

src/paimon/global_index/lucene/jieba_analyzer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class JiebaTokenizer : public Lucene::Tokenizer {
4646

4747
bool incrementToken() override;
4848

49+
void reset(const Lucene::ReaderPtr& input) override;
50+
4951
void reset() override;
5052

5153
static void CutWithMode(const std::string& tokenize_mode, const cppjieba::Jieba* jieba,
@@ -55,6 +57,9 @@ class JiebaTokenizer : public Lucene::Tokenizer {
5557
static void Normalize(const std::unordered_set<std::string>& stop_words,
5658
std::vector<std::string>* input, std::vector<std::string_view>* output);
5759

60+
private:
61+
void InnerReset();
62+
5863
private:
5964
JiebaTokenizerContext context_;
6065
size_t term_index_ = 0;

src/paimon/global_index/lucene/lucene_global_index_reader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class LuceneGlobalIndexReader : public GlobalIndexReader {
9393
return CreateAllResult();
9494
}
9595

96+
Result<std::shared_ptr<GlobalIndexResult>> VisitLike(const Literal& literal) override {
97+
return CreateAllResult();
98+
}
99+
96100
Result<std::shared_ptr<VectorSearchGlobalIndexResult>> VisitVectorSearch(
97101
const std::shared_ptr<VectorSearch>& vector_search) override {
98102
return Status::Invalid(

0 commit comments

Comments
 (0)