Skip to content

Commit c4e9208

Browse files
committed
fix0253
1 parent 1495b84 commit c4e9208

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

src/paimon/global_index/lucene/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if(PAIMON_ENABLE_LUCENE)
1616
set(PAIMON_LUCENE
1717
lucene_global_index.cpp
1818
lucene_directory.cpp
19+
lucene_utils.cpp
1920
jieba_analyzer.cpp
2021
lucene_global_index_writer.cpp
2122
lucene_global_index_reader.cpp
@@ -41,6 +42,12 @@ if(PAIMON_ENABLE_LUCENE)
4142
paimon_shared
4243
SHARED_LINK_FLAGS
4344
${PAIMON_VERSION_SCRIPT_FLAGS})
45+
if(PAIMON_BUILD_TESTS)
46+
target_compile_definitions(paimon_lucene_index_objlib
47+
PRIVATE JIEBA_TEST_DICT_DIR="${JIEBA_DICT_DIR}")
48+
49+
endif()
50+
4451

4552
if(PAIMON_BUILD_TESTS)
4653
add_paimon_test(lucene_index_test
@@ -61,8 +68,6 @@ if(PAIMON_ENABLE_LUCENE)
6168
paimon_lucene_index_static
6269
"-Wl,--no-whole-archive"
6370
${GTEST_LINK_TOOLCHAIN})
64-
target_compile_definitions(paimon-lucene-index-test
65-
PUBLIC JIEBA_TEST_DICT_DIR="${JIEBA_DICT_DIR}")
6671

6772
endif()
6873
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2026-present Alibaba Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "paimon/global_index/lucene/lucene_utils.h"
17+
namespace paimon::lucene {
18+
19+
Result<std::string> LuceneUtils::GetJiebaDictionaryDir() {
20+
const char* env_dir = std::getenv(kJiebaDictDirEnv);
21+
if (env_dir && *env_dir != '\0') {
22+
return std::string(env_dir);
23+
}
24+
#ifdef JIEBA_TEST_DICT_DIR
25+
return std::string(JIEBA_TEST_DICT_DIR);
26+
#endif
27+
return Status::Invalid(
28+
fmt::format("cannot get dictionary dir for jieba, must set env {}", kJiebaDictDirEnv));
29+
}
30+
31+
} // namespace paimon::lucene

src/paimon/global_index/lucene/lucene_utils.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ class LuceneUtils {
3434
return Lucene::StringUtils::toUTF8(wstr);
3535
}
3636

37-
static Result<std::string> GetJiebaDictionaryDir() {
38-
const char* env_dir = std::getenv(kJiebaDictDirEnv);
39-
if (env_dir && *env_dir != '\0') {
40-
return std::string(env_dir);
41-
}
42-
#ifdef JIEBA_TEST_DICT_DIR
43-
return std::string(JIEBA_TEST_DICT_DIR);
44-
#endif
45-
return Status::Invalid(
46-
fmt::format("cannot get dictionary dir for jieba, must set env {}", kJiebaDictDirEnv));
47-
}
37+
static Result<std::string> GetJiebaDictionaryDir();
4838
};
4939
} // namespace paimon::lucene

0 commit comments

Comments
 (0)