feat(tantivy): Add Tantivy full-text search with on-demand archive reading#231
Merged
JingsongLi merged 2 commits intoapache:mainfrom Apr 9, 2026
Merged
feat(tantivy): Add Tantivy full-text search with on-demand archive reading#231JingsongLi merged 2 commits intoapache:mainfrom
JingsongLi merged 2 commits intoapache:mainfrom
Conversation
…ading Introduce a complete Tantivy-based full-text search pipeline for global indexes, with on-demand I/O throughout: - ArchiveDirectory: reads only the archive header eagerly; file data is loaded via async FileRead when Tantivy requests it (sync-to-async bridge using std::thread::scope). - TantivyFullTextWriter: streams the packed archive directly to an OutputFile instead of buffering in memory. - TantivyFullTextReader: opens from InputFile/FileRead, never loads the full archive into memory. - FullTextSearchBuilder: self-contained builder on Table that reads the index manifest, evaluates searches against multiple Tantivy indexes in parallel (try_join_all), and returns ScoredGlobalIndexResult. - ScoredGlobalIndexResult + bitmap_to_ranges moved to table/source.rs (alongside RowRange) so vector search can reuse them later. - TableScan.with_row_ranges(): generic row-range filtering, decoupled from full-text specifics. - DataFusion full_text_search UDTF integration with test data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jerry-024
reviewed
Apr 9, 2026
jerry-024
left a comment
There was a problem hiding this comment.
1. Unsafe integer casts in archive parsing (crates/paimon/src/tantivy/directory.rs)
i32::from_be_bytes(...) as usize for file_count — if the archive is corrupt or malicious and file_count is negative, this wraps to a very large usize, causing OOM or panic in HashMap::with_capacity.
Same issue with i64::from_be_bytes(...) as u64 for data_len — a negative value wraps to a huge offset.
Suggest validating both are non-negative before casting:
let file_count = i32::from_be_bytes([buf[0], buf[1], buf[2], buf[3]]);
if file_count < 0 {
return Err(io::Error::new(io::ErrorKind::InvalidData, "Negative file count in archive"));
}
let file_count = file_count as usize;(and similarly for data_len)
2. UInt64 as i64 can silently overflow (crates/integrations/datafusion/src/full_text_search.rs)
In extract_int_literal: ScalarValue::UInt64(Some(v)) => Ok(*v as i64) — values greater than i64::MAX silently wrap to negative, which then fails the limit <= 0 check with a confusing error, or worse passes through.
Suggest:
ScalarValue::UInt64(Some(v)) => i64::try_from(*v).map_err(|_| {
datafusion::error::DataFusionError::Plan(
format!("full_text_search: {name} value {v} exceeds i64 range")
)
}),
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Subtask of #227
Introduce a complete Tantivy-based full-text search pipeline for global indexes, with on-demand I/O throughout:
Brief change log
Tests
API and Format
Documentation