diff --git a/be/test/olap/rowset/segment_v2/inverted_index_array_test.cpp b/be/test/olap/rowset/segment_v2/inverted_index_array_test.cpp index 469f5243c79f5e..8621b81518af80 100644 --- a/be/test/olap/rowset/segment_v2/inverted_index_array_test.cpp +++ b/be/test/olap/rowset/segment_v2/inverted_index_array_test.cpp @@ -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 reader = - std::make_unique(index_input, 4096); + void check_terms_stats(string file_str) { + std::unique_ptr 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(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(); @@ -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(); index_meta_pb->set_index_type(IndexType::INVERTED); index_meta_pb->set_index_id(index_id); @@ -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); } };