Skip to content

Commit b80aecf

Browse files
authored
Merge branch 'main' into spill-pr1
2 parents 0c9920f + e2a73de commit b80aecf

55 files changed

Lines changed: 2598 additions & 520 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.

include/paimon/global_index/global_index_io_meta.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@
2525
namespace paimon {
2626
/// Metadata describing a single file entry in a global index.
2727
struct PAIMON_EXPORT GlobalIndexIOMeta {
28-
GlobalIndexIOMeta(const std::string& _file_path, int64_t _file_size, int64_t _range_end,
28+
GlobalIndexIOMeta(const std::string& _file_path, int64_t _file_size,
2929
const std::shared_ptr<Bytes>& _metadata)
30-
: file_path(_file_path),
31-
file_size(_file_size),
32-
range_end(_range_end),
33-
metadata(_metadata) {}
30+
: file_path(_file_path), file_size(_file_size), metadata(_metadata) {}
3431

3532
std::string file_path;
3633
int64_t file_size;
37-
/// The inclusive range end covered by this file (i.e., the last local row id).
38-
int64_t range_end;
3934
/// Optional binary metadata associated with the file, such as serialized
4035
/// secondary index structures or inline index bytes.
4136
/// May be null if no additional metadata is available.

include/paimon/global_index/global_index_writer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class PAIMON_EXPORT GlobalIndexWriter {
3434
///
3535
/// @param arrow_array A valid C ArrowArray pointer representing a struct array.
3636
/// Must not be nullptr, and must conform to the expected schema.
37+
/// @param relative_row_ids local row id calculated by {@code row_id - range.from}.
3738
/// @return `Status::OK()` on success; otherwise, an error indicating malformed
3839
/// input, I/O failure, or unsupported type, etc.
39-
virtual Status AddBatch(::ArrowArray* arrow_array) = 0;
40+
virtual Status AddBatch(::ArrowArray* arrow_array, std::vector<int64_t>&& relative_row_ids) = 0;
4041

4142
/// Finalizes the index build process and returns metadata for persisted index.
4243
virtual Result<std::vector<GlobalIndexIOMeta>> Finish() = 0;

src/paimon/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ if(PAIMON_BUILD_TESTS)
410410
common/file_index/bloomfilter/fast_hash_test.cpp
411411
common/global_index/complete_index_score_batch_reader_test.cpp
412412
common/global_index/global_index_result_test.cpp
413+
common/global_index/global_index_utils_test.cpp
413414
common/global_index/global_indexer_factory_test.cpp
414415
common/global_index/bitmap_global_index_result_test.cpp
415416
common/global_index/bitmap_scored_global_index_result_test.cpp
@@ -419,6 +420,8 @@ if(PAIMON_BUILD_TESTS)
419420
common/global_index/btree/key_serializer_test.cpp
420421
common/global_index/btree/btree_global_index_integration_test.cpp
421422
common/global_index/btree/btree_compatibility_test.cpp
423+
common/global_index/btree/btree_file_meta_selector_test.cpp
424+
common/global_index/btree/lazy_filtered_btree_reader_test.cpp
422425
common/global_index/rangebitmap/range_bitmap_global_index_test.cpp
423426
common/global_index/wrap/file_index_reader_wrapper_test.cpp
424427
common/io/byte_array_input_stream_test.cpp

src/paimon/common/global_index/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ set(PAIMON_GLOBAL_INDEX_SRC
2020
btree/btree_global_indexer.cpp
2121
btree/btree_global_index_reader.cpp
2222
btree/btree_global_index_writer.cpp
23+
btree/btree_file_meta_selector.cpp
2324
btree/btree_index_meta.cpp
25+
btree/lazy_filtered_btree_reader.cpp
2426
btree/key_serializer.cpp
2527
rangebitmap/range_bitmap_global_index.cpp
2628
rangebitmap/range_bitmap_global_index_factory.cpp)

src/paimon/common/global_index/bitmap/bitmap_global_index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Result<std::shared_ptr<GlobalIndexReader>> BitmapGlobalIndex::CreateReader(
4242
PAIMON_ASSIGN_OR_RAISE(
4343
std::shared_ptr<FileIndexReader> reader,
4444
index_->CreateReader(arrow_schema, /*start=*/0, meta.file_size, in, pool));
45-
auto transform = [range_end = meta.range_end](const std::shared_ptr<FileIndexResult>& result)
45+
auto transform = [](const std::shared_ptr<FileIndexResult>& result)
4646
-> Result<std::shared_ptr<GlobalIndexResult>> {
47-
return FileIndexReaderWrapper::ToGlobalIndexResult(range_end, result);
47+
return FileIndexReaderWrapper::ToGlobalIndexResult(result);
4848
};
4949
return std::make_shared<BitmapGlobalIndexReader>(reader, transform);
5050
}

src/paimon/common/global_index/bitmap/bitmap_global_index_test.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ class BitmapGlobalIndexTest : public ::testing::Test {
7575

7676
ArrowArray c_array;
7777
PAIMON_RETURN_NOT_OK_FROM_ARROW(arrow::ExportArray(*array, &c_array));
78-
PAIMON_RETURN_NOT_OK(global_writer->AddBatch(&c_array));
78+
std::vector<int64_t> row_ids(array->length());
79+
std::iota(row_ids.begin(), row_ids.end(), 0);
80+
PAIMON_RETURN_NOT_OK(global_writer->AddBatch(&c_array, std::move(row_ids)));
7981
PAIMON_ASSIGN_OR_RAISE(auto result_metas, global_writer->Finish());
8082
// check meta
8183
if (result_metas.empty()) {
@@ -85,7 +87,6 @@ class BitmapGlobalIndexTest : public ::testing::Test {
8587
auto file_name = PathUtil::GetName(result_metas[0].file_path);
8688
EXPECT_TRUE(StringUtils::StartsWith(file_name, "bitmap-global-index-"));
8789
EXPECT_TRUE(StringUtils::EndsWith(file_name, ".index"));
88-
EXPECT_EQ(result_metas[0].range_end, expected_range.to);
8990
EXPECT_FALSE(result_metas[0].metadata);
9091
return result_metas[0];
9192
}
@@ -161,19 +162,19 @@ TEST_F(BitmapGlobalIndexTest, TestStringType) {
161162

162163
// greater than return REMAIN file index result, will convert to all range global index
163164
// result
164-
CheckResult(reader->VisitGreaterThan(lit_c).value(), {0, 1, 2, 3, 4});
165+
ASSERT_FALSE(reader->VisitGreaterThan(lit_c).value());
165166

166167
// test visit vector search
167168
ASSERT_NOK_WITH_MSG(reader->VisitVectorSearch(std::make_shared<VectorSearch>(
168169
"f0", 10, std::vector<float>({1.0f, 2.0f}), nullptr, nullptr,
169170
std::nullopt, std::map<std::string, std::string>())),
170171
"FileIndexReaderWrapper is not supposed to handle vector search query");
171172
// test VisitStartsWith, VisitEndsWith, VisitContains, VisitLike, VisitFullTextSearch
172-
CheckResult(reader->VisitStartsWith(lit_c).value(), {0, 1, 2, 3, 4});
173-
CheckResult(reader->VisitEndsWith(lit_c).value(), {0, 1, 2, 3, 4});
174-
CheckResult(reader->VisitContains(lit_c).value(), {0, 1, 2, 3, 4});
175-
CheckResult(reader->VisitLike(lit_c).value(), {0, 1, 2, 3, 4});
176-
CheckResult(reader->VisitFullTextSearch(nullptr).value(), {0, 1, 2, 3, 4});
173+
ASSERT_FALSE(reader->VisitStartsWith(lit_c).value());
174+
ASSERT_FALSE(reader->VisitEndsWith(lit_c).value());
175+
ASSERT_FALSE(reader->VisitContains(lit_c).value());
176+
ASSERT_FALSE(reader->VisitLike(lit_c).value());
177+
ASSERT_FALSE(reader->VisitFullTextSearch(nullptr).value());
177178
};
178179

179180
{

0 commit comments

Comments
 (0)