Skip to content

Commit

Permalink
[fix] (UT) fix be ut InvertedIndexArrayTest (apache#40090)
Browse files Browse the repository at this point in the history
## Proposed changes

fix be ut InvertedIndexArrayTest

<!--Describe your changes.-->
  • Loading branch information
csun5285 authored Aug 29, 2024
1 parent 664ca8a commit d7eb343
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions be/test/olap/rowset/segment_v2/inverted_index_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ class InvertedIndexArrayTest : public testing::Test {
public:
const std::string kTestDir = "./ut_dir/inverted_index_array_test";

void check_terms_stats(string dir_str, string file_str) {
CLuceneError err;
CL_NS(store)::IndexInput* index_input = nullptr;
DorisFSDirectory::FSIndexInput::open(io::global_local_filesystem(), file_str.c_str(),
index_input, err, 4096);
std::unique_ptr<DorisCompoundReader> reader =
std::make_unique<DorisCompoundReader>(index_input, 4096);
void check_terms_stats(string file_str) {
std::unique_ptr<DorisCompoundReader> reader;
try {
CLuceneError err;
CL_NS(store)::IndexInput* index_input = nullptr;
auto ok = DorisFSDirectory::FSIndexInput::open(
io::global_local_filesystem(), file_str.c_str(), index_input, err, 4096);
if (!ok) {
throw err;
}
reader = std::make_unique<DorisCompoundReader>(index_input, 4096);
} catch (...) {
EXPECT_TRUE(false);
}

std::cout << "Term statistics for " << file_str << std::endl;
std::cout << "==================================" << std::endl;
lucene::store::Directory* dir = reader.get();
Expand Down Expand Up @@ -121,8 +129,6 @@ class InvertedIndexArrayTest : public testing::Test {
InvertedIndexDescriptor::get_index_file_path_v1(index_path_prefix, index_id, "");
auto fs = io::global_local_filesystem();

io::FileWriterPtr file_writer;
EXPECT_TRUE(fs->create_file(index_path, &file_writer).ok());
auto index_meta_pb = std::make_unique<TabletIndexPB>();
index_meta_pb->set_index_type(IndexType::INVERTED);
index_meta_pb->set_index_id(index_id);
Expand Down Expand Up @@ -204,7 +210,7 @@ class InvertedIndexArrayTest : public testing::Test {
EXPECT_EQ(_inverted_index_builder->finish(), Status::OK());
EXPECT_EQ(index_file_writer->close(), Status::OK());

check_terms_stats(file_writer->path().parent_path(), file_writer->path().filename());
check_terms_stats(index_path);
}
};

Expand Down

0 comments on commit d7eb343

Please sign in to comment.