2323#include < string>
2424#include < vector>
2525
26+ #include " paimon/global_index/global_index_result.h"
2627#include " paimon/predicate/predicate.h"
2728#include " paimon/result.h"
2829#include " paimon/type_fwd.h"
29- #include " paimon/utils/range.h"
3030#include " paimon/visibility.h"
31-
3231namespace paimon {
3332class ScanContextBuilder ;
3433class ScanFilter ;
@@ -45,6 +44,7 @@ class PAIMON_EXPORT ScanContext {
4544 public:
4645 ScanContext (const std::string& path, bool is_streaming_mode, std::optional<int32_t > limit,
4746 const std::shared_ptr<ScanFilter>& scan_filter,
47+ const std::shared_ptr<GlobalIndexResult>& global_index_result,
4848 const std::shared_ptr<MemoryPool>& memory_pool,
4949 const std::shared_ptr<Executor>& executor,
5050 const std::map<std::string, std::string>& options);
@@ -77,12 +77,16 @@ class PAIMON_EXPORT ScanContext {
7777 std::shared_ptr<Executor> GetExecutor () const {
7878 return executor_;
7979 }
80+ std::shared_ptr<GlobalIndexResult> GetGlobalIndexResult () const {
81+ return global_index_result_;
82+ }
8083
8184 private:
8285 std::string path_;
8386 bool is_streaming_mode_;
8487 std::optional<int32_t > limit_;
8588 std::shared_ptr<ScanFilter> scan_filters_;
89+ std::shared_ptr<GlobalIndexResult> global_index_result_;
8690 std::shared_ptr<MemoryPool> memory_pool_;
8791 std::shared_ptr<Executor> executor_;
8892 std::map<std::string, std::string> options_;
@@ -93,11 +97,10 @@ class PAIMON_EXPORT ScanFilter {
9397 public:
9498 ScanFilter (const std::shared_ptr<Predicate>& predicate,
9599 const std::vector<std::map<std::string, std::string>>& partition_filters,
96- const std::optional<int32_t >& bucket_filter, const std::vector<Range>& row_ranges )
100+ const std::optional<int32_t >& bucket_filter)
97101 : predicates_(predicate),
98102 bucket_filter_ (bucket_filter),
99- partition_filters_(partition_filters),
100- row_ranges_(row_ranges) {}
103+ partition_filters_(partition_filters) {}
101104
102105 std::shared_ptr<Predicate> GetPredicate () const {
103106 return predicates_;
@@ -109,15 +112,10 @@ class PAIMON_EXPORT ScanFilter {
109112 return partition_filters_;
110113 }
111114
112- const std::vector<Range>& GetRowRanges () const {
113- return row_ranges_;
114- }
115-
116115 private:
117116 std::shared_ptr<Predicate> predicates_;
118117 std::optional<int32_t > bucket_filter_;
119118 std::vector<std::map<std::string, std::string>> partition_filters_;
120- std::vector<Range> row_ranges_;
121119};
122120
123121// / `ScanContextBuilder` used to build a `ScanContext`, has input validation.
@@ -138,10 +136,11 @@ class PAIMON_EXPORT ScanContextBuilder {
138136 // / Set a predicate for filtering data.
139137 ScanContextBuilder& SetPredicate (const std::shared_ptr<Predicate>& predicate);
140138
141- // / Specify the row id ranges for scan. This is usually used to read specific rows in
142- // / data-evolution mode. File ranges that do not have any intersection with range_ids will be
143- // / filtered. If not set, all rows are returned
144- ScanContextBuilder& SetRowRanges (const std::vector<Range>& row_ranges);
139+ // / Sets the result of a global index search (e.g., row ids (may with scores) from a distributed
140+ // / index lookup). This is used to push down index-filtered row ids into the scan for efficient
141+ // / data retrieval.
142+ ScanContextBuilder& SetGlobalIndexResult (
143+ const std::shared_ptr<GlobalIndexResult>& global_index_result);
145144 // / The options added or set in `ScanContextBuilder` have high priority and will be merged with
146145 // / the options in table schema.
147146 ScanContextBuilder& AddOption (const std::string& key, const std::string& value);
0 commit comments