Skip to content

Commit a099fee

Browse files
authored
feat(lumina): support Lumina tag filtering (alibaba#404)
1 parent 30dcf83 commit a099fee

22 files changed

Lines changed: 1635 additions & 75 deletions

include/paimon/global_index/global_index_io_meta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
#pragma once
1818

19+
#include <cstdint>
1920
#include <memory>
2021
#include <string>
2122

2223
#include "paimon/memory/bytes.h"
23-
#include "paimon/utils/range.h"
2424

2525
namespace paimon {
2626
/// Metadata describing a single file entry in a global index.

include/paimon/global_index/global_indexer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#pragma once
1818

1919
#include <memory>
20+
#include <optional>
2021
#include <string>
2122
#include <vector>
2223

@@ -36,6 +37,9 @@ class PAIMON_EXPORT GlobalIndexer {
3637
public:
3738
virtual ~GlobalIndexer() = default;
3839

40+
/// Returns additional table fields required during index construction.
41+
virtual Result<std::optional<std::vector<std::string>>> GetExtraFieldNames() const = 0;
42+
3943
/// Creates a writer for building a global index on a specific field.
4044
///
4145
/// @param field_name Name of the field to be indexed.

include/paimon/predicate/vector_search.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ struct PAIMON_EXPORT VectorSearch {
7474
/// context-aware filtering at query time.
7575
/// @note All fields referenced in the predicate must have been materialized
7676
/// in the index during build to ensure availability.
77+
/// @note For tag-based vector indexes, fields referenced by the predicate
78+
/// must keep the same names and types as the fields used during index
79+
/// construction. Indexes built with tag fields must not be reused across
80+
/// schema evolution that renames or changes those tag fields.
7781
std::shared_ptr<Predicate> predicate;
7882
/// The distance metric to use for this query, if explicitly specified.
7983
/// If set, this value must match the distance type used by the index (e.g., EUCLIDEAN, COSINE).

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "paimon/common/global_index/wrap/file_index_writer_wrapper.h"
2020

2121
namespace paimon {
22+
Result<std::optional<std::vector<std::string>>> BitmapGlobalIndex::GetExtraFieldNames() const {
23+
return std::optional<std::vector<std::string>>(std::nullopt);
24+
}
25+
2226
Result<std::shared_ptr<GlobalIndexWriter>> BitmapGlobalIndex::CreateWriter(
2327
const std::string& field_name, ::ArrowSchema* arrow_schema,
2428
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#pragma once
1818

1919
#include <memory>
20+
#include <optional>
2021
#include <string>
2122
#include <vector>
2223

@@ -29,6 +30,8 @@ class BitmapGlobalIndex : public GlobalIndexer {
2930
public:
3031
explicit BitmapGlobalIndex(const std::shared_ptr<BitmapFileIndex>& index) : index_(index) {}
3132

33+
Result<std::optional<std::vector<std::string>>> GetExtraFieldNames() const override;
34+
3235
Result<std::shared_ptr<GlobalIndexWriter>> CreateWriter(
3336
const std::string& field_name, ::ArrowSchema* arrow_schema,
3437
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

src/paimon/common/global_index/btree/btree_global_indexer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ Result<std::unique_ptr<BTreeGlobalIndexer>> BTreeGlobalIndexer::Create(
5454
return std::unique_ptr<BTreeGlobalIndexer>(new BTreeGlobalIndexer(cache_manager, options));
5555
}
5656

57+
Result<std::optional<std::vector<std::string>>> BTreeGlobalIndexer::GetExtraFieldNames() const {
58+
return std::optional<std::vector<std::string>>(std::nullopt);
59+
}
60+
5761
Result<std::shared_ptr<GlobalIndexWriter>> BTreeGlobalIndexer::CreateWriter(
5862
const std::string& field_name, ::ArrowSchema* arrow_schema,
5963
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

src/paimon/common/global_index/btree/btree_global_indexer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class BTreeGlobalIndexer : public GlobalIndexer {
5353
static Result<std::unique_ptr<BTreeGlobalIndexer>> Create(
5454
const std::map<std::string, std::string>& options);
5555

56+
Result<std::optional<std::vector<std::string>>> GetExtraFieldNames() const override;
57+
5658
Result<std::shared_ptr<GlobalIndexWriter>> CreateWriter(
5759
const std::string& field_name, ::ArrowSchema* arrow_schema,
5860
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

src/paimon/common/global_index/rangebitmap/range_bitmap_global_index.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "paimon/common/global_index/wrap/file_index_writer_wrapper.h"
2020

2121
namespace paimon {
22+
Result<std::optional<std::vector<std::string>>> RangeBitmapGlobalIndex::GetExtraFieldNames() const {
23+
return std::optional<std::vector<std::string>>(std::nullopt);
24+
}
25+
2226
Result<std::shared_ptr<GlobalIndexWriter>> RangeBitmapGlobalIndex::CreateWriter(
2327
const std::string& field_name, ::ArrowSchema* arrow_schema,
2428
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

src/paimon/common/global_index/rangebitmap/range_bitmap_global_index.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#pragma once
1818

1919
#include <memory>
20+
#include <optional>
2021
#include <string>
2122
#include <vector>
2223

@@ -30,6 +31,8 @@ class RangeBitmapGlobalIndex : public GlobalIndexer {
3031
explicit RangeBitmapGlobalIndex(const std::shared_ptr<RangeBitmapFileIndex>& index)
3132
: index_(index) {}
3233

34+
Result<std::optional<std::vector<std::string>>> GetExtraFieldNames() const override;
35+
3336
Result<std::shared_ptr<GlobalIndexWriter>> CreateWriter(
3437
const std::string& field_name, ::ArrowSchema* arrow_schema,
3538
const std::shared_ptr<GlobalIndexFileWriter>& file_writer,

src/paimon/common/reader/data_evolution_file_reader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "paimon/common/reader/reader_utils.h"
2424
#include "paimon/common/utils/arrow/mem_utils.h"
2525
#include "paimon/common/utils/arrow/status_utils.h"
26+
2627
namespace paimon {
2728
Result<std::unique_ptr<DataEvolutionFileReader>> DataEvolutionFileReader::Create(
2829
std::vector<std::unique_ptr<BatchReader>>&& readers,
@@ -165,11 +166,10 @@ Result<std::shared_ptr<arrow::Array>> DataEvolutionFileReader::NextBatchForSingl
165166
if (concat_array_vec.empty()) {
166167
return std::shared_ptr<arrow::Array>();
167168
}
168-
if (concat_array_vec.size() == 1) {
169-
// avoid data copy
169+
if (concat_array_vec.size() == 1 && concat_array_vec[0]->offset() == 0) {
170+
// Avoid data copy when the array is already normalized.
170171
return concat_array_vec[0];
171172
}
172-
// TODO(xinyu.lxy) remove data copy for efficiency
173173
PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::Array> concat_array,
174174
arrow::Concatenate(concat_array_vec, arrow_pool_.get()));
175175
assert(concat_array->length() == total_array_length);

0 commit comments

Comments
 (0)