@@ -52,23 +52,26 @@ struct VectorSearch;
5252// / @see ReadContextBuilder
5353class PAIMON_EXPORT ReadContext {
5454 public:
55- ReadContext (
56- const std::string& path, const std::string& branch,
57- const std::vector<std::string>& read_field_names,
58- const std::vector<int32_t >& read_field_ids, const std::shared_ptr<Predicate>& predicate,
59- const std::shared_ptr<VectorSearch>& vector_search,
60- const std::shared_ptr<FullTextSearch>& full_text_search, bool enable_predicate_filter,
61- bool enable_prefetch, bool enable_late_materializing, uint32_t prefetch_batch_count,
62- uint32_t prefetch_max_parallel_num, bool enable_multi_thread_row_to_batch,
63- uint32_t row_to_batch_thread_number, const std::optional<std::string>& table_schema,
64- const std::shared_ptr<MemoryPool>& memory_pool, const std::shared_ptr<Executor>& executor,
65- const std::shared_ptr<FileSystem>& specific_file_system,
66- const std::map<std::string, std::string>& fs_scheme_to_identifier_map,
67- const std::shared_ptr<RealtimeContext>& realtime_context,
68- const std::map<std::string, std::string>& options, bool read_ahead_cache_enabled,
69- const CacheConfig& cache_config, const std::shared_ptr<Cache>& cache,
70- const std::shared_ptr<FormatTable>& format_table, WarmupLevel warmup_level,
71- const std::shared_ptr<Catalog>& catalog, const std::optional<Identifier>& identifier);
55+ ReadContext (const std::string& path, const std::string& branch,
56+ const std::vector<std::string>& read_field_names,
57+ const std::vector<int32_t >& read_field_ids,
58+ const std::shared_ptr<Predicate>& predicate,
59+ const std::shared_ptr<VectorSearch>& vector_search,
60+ const std::shared_ptr<FullTextSearch>& full_text_search,
61+ bool enable_precise_file_index_evaluate, bool enable_predicate_filter,
62+ bool enable_prefetch, bool enable_late_materializing, uint32_t prefetch_batch_count,
63+ uint32_t prefetch_max_parallel_num, bool enable_multi_thread_row_to_batch,
64+ uint32_t row_to_batch_thread_number, const std::optional<std::string>& table_schema,
65+ const std::shared_ptr<MemoryPool>& memory_pool,
66+ const std::shared_ptr<Executor>& executor,
67+ const std::shared_ptr<FileSystem>& specific_file_system,
68+ const std::map<std::string, std::string>& fs_scheme_to_identifier_map,
69+ const std::shared_ptr<RealtimeContext>& realtime_context,
70+ const std::map<std::string, std::string>& options, bool read_ahead_cache_enabled,
71+ const CacheConfig& cache_config, const std::shared_ptr<Cache>& cache,
72+ const std::shared_ptr<FormatTable>& format_table, WarmupLevel warmup_level,
73+ const std::shared_ptr<Catalog>& catalog,
74+ const std::optional<Identifier>& identifier);
7275
7376 ~ReadContext ();
7477
@@ -113,6 +116,10 @@ class PAIMON_EXPORT ReadContext {
113116 return vector_search_ != nullptr || full_text_search_ != nullptr ;
114117 }
115118
119+ bool EnablePreciseFileIndexEvaluate () const {
120+ return enable_precise_file_index_evaluate_;
121+ }
122+
116123 bool EnablePredicateFilter () const {
117124 return enable_predicate_filter_;
118125 }
@@ -208,6 +215,7 @@ class PAIMON_EXPORT ReadContext {
208215 std::shared_ptr<Predicate> predicate_;
209216 std::shared_ptr<VectorSearch> vector_search_;
210217 std::shared_ptr<FullTextSearch> full_text_search_;
218+ bool enable_precise_file_index_evaluate_;
211219 bool enable_predicate_filter_;
212220 bool enable_prefetch_;
213221 bool enable_late_materializing_;
@@ -352,39 +360,52 @@ class PAIMON_EXPORT ReadContextBuilder {
352360 // /
353361 // / All referenced fields, including full-text match fields, must be projected in the read
354362 // / schema.
355- // / TODO(lisizhuo.lsz): The behavior here will be aligned with Java Paimon in a follow-up
356- // / change: fields referenced in predicates will no longer be required to appear in the
357- // / projection. Full-text matches can be combined with scalar predicates using
358- // / PredicateBuilder::And/Or. Full-text predicate execution is not implemented yet; reading such
359- // / a predicate returns NotImplemented .
363+ // / TODO(lisizhuo.lsz): Align with Java Paimon so fields referenced by predicates no longer need
364+ // / to appear in the projection.
365+ // / Full-text matches can be combined with scalar predicates using PredicateBuilder::And/Or.
366+ // / Predicates on virtual index score columns (_INDEX_SCORE or _<field>_INDEX_SCORE) are not
367+ // / supported .
360368 // /
361369 // / @param predicate Shared pointer to the predicate for data filtering.
362370 // / @return Reference to this builder for method chaining.
371+ // / @note Predicates containing FullTextMatch require EnablePreciseFileIndexEvaluate(true).
363372 ReadContextBuilder& SetPredicate (const std::shared_ptr<Predicate>& predicate);
364373
365374 // / Configure the root vector TopK request, logically applied after the predicate filter.
366375 // / The search field need not be projected. SetVectorSearch is mutually exclusive with
367376 // / SetFullTextSearch and must have a positive limit.
368377 // / Scores are required internally for TopK. Project `_<field>_INDEX_SCORE` to include them
369- // / in the result. Per-field score output is not implemented yet; reading such a projection
370- // / returns NotImplemented.
371- // / TODO(lisizhuo.lsz): Execute combined read predicates and merge TopK across files.
378+ // / in the result.
379+ // / TODO(lisizhuo.lsz): Merge TopK across files.
372380 // / @param vector_search Vector search request, or nullptr to clear it.
373381 // / @return Reference to this builder for method chaining.
382+ // / @note Requires EnablePreciseFileIndexEvaluate(true).
374383 ReadContextBuilder& SetVectorSearch (const std::shared_ptr<VectorSearch>& vector_search);
375384
376385 // / Configure the root full-text TopK request, logically applied after the predicate filter.
377386 // / The search field need not be projected. Use PredicateBuilder::FullTextMatch for a
378387 // / full-text filter without TopK truncation. SetFullTextSearch is mutually exclusive with
379388 // / SetVectorSearch and must have a positive limit.
380389 // / Scores are required internally for TopK. Project `_<field>_INDEX_SCORE` to include them
381- // / in the result. Per-field score output is not implemented yet; reading such a projection
382- // / returns NotImplemented.
383- // / TODO(lisizhuo.lsz): Execute combined read predicates and merge TopK across files.
390+ // / in the result.
391+ // / TODO(lisizhuo.lsz): Merge TopK across files.
384392 // / @param full_text_search Full-text search request, or nullptr to clear it.
385393 // / @return Reference to this builder for method chaining.
394+ // / @note Requires EnablePreciseFileIndexEvaluate(true).
386395 ReadContextBuilder& SetFullTextSearch (const std::shared_ptr<FullTextSearch>& full_text_search);
387396
397+ // / Compute exact file-local result row positions during file-index evaluation, using the
398+ // / configured Predicate and optional VectorSearch or FullTextSearch request.
399+ // / Requires file-index.read.enabled=true. Reads available file indexes and rechecks scalar
400+ // / index candidates against the data. If a scalar predicate's field has no index, reads the
401+ // / data to compute exact matching rows. Only scalar predicates may be evaluated without an
402+ // / index. Score output must use named projections such as _<field>_INDEX_SCORE;
403+ // / projecting _INDEX_SCORE by name, field ID or read schema is not supported in this mode.
404+ // / The default is false.
405+ // / @param enabled Whether to compute exact result row positions during file-index evaluation.
406+ // / @return Reference to this builder for method chaining.
407+ ReadContextBuilder& EnablePreciseFileIndexEvaluate (bool enabled);
408+
388409 // / Whether to perform precise filtering according to predicates for data read from format
389410 // / reader.
390411 // / @param enabled Whether to enable precise filtering (default: false)
0 commit comments