-
Notifications
You must be signed in to change notification settings - Fork 849
feat(fts): read inverted index params without opening the segment #7816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4113,3 +4113,50 @@ async fn test_manifest_read_recovers_from_stale_size() { | |
| assert_eq!(indices.len(), 1); | ||
| assert_eq!(indices[0].name, "id_idx"); | ||
| } | ||
|
|
||
| /// `load_segment_params` must match the fully opened segment's params, | ||
| /// including `custom_stop_words` — the field `InvertedIndexDetails` loses. | ||
| #[tokio::test] | ||
| async fn test_load_segment_params_full_fidelity() { | ||
| use crate::index::DatasetIndexInternalExt; | ||
| use lance_index::metrics::NoOpMetricsCollector; | ||
| use lance_index::scalar::inverted::InvertedIndex; | ||
|
|
||
| let batch = RecordBatch::try_new( | ||
| arrow_schema::Schema::new(vec![Field::new("text", DataType::Utf8, false)]).into(), | ||
| vec![Arc::new(StringArray::from(vec![ | ||
| "the quick brown fox", | ||
| "lazy dogs sleep", | ||
| ]))], | ||
| ) | ||
| .unwrap(); | ||
| let schema = batch.schema(); | ||
| let stream = RecordBatchIterator::new(vec![batch].into_iter().map(Ok), schema); | ||
| let mut dataset = Dataset::write(stream, "memory://test/segment_params", None) | ||
| .await | ||
| .unwrap(); | ||
|
Comment on lines
+4121
to
+4137
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Use the standard Rust test setup conventions. Move the As per coding guidelines, “Place 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| let params = InvertedIndexParams::default().custom_stop_words(Some(vec!["quick".to_string()])); | ||
| dataset | ||
| .create_index(&["text"], IndexType::Inverted, None, ¶ms, true) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let segments = crate::index::scalar::load_segments(&dataset, "text") | ||
| .await | ||
| .unwrap() | ||
| .expect("FTS index segments"); | ||
| let read = crate::index::scalar::load_segment_params(&dataset, &segments[0]) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let generic = dataset | ||
| .open_generic_index("text", &segments[0].uuid, &NoOpMetricsCollector) | ||
| .await | ||
| .unwrap(); | ||
| let opened = generic | ||
| .as_any() | ||
| .downcast_ref::<InvertedIndex>() | ||
| .expect("inverted index"); | ||
| assert_eq!(&read, opened.params()); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: lance-format/lance
Length of output: 1922
🏁 Script executed:
Repository: lance-format/lance
Length of output: 1922
Only fall back when the metadata file is missing.
Err(_)here treats permission, I/O, and corrupt-metadata failures as the legacy format, which hides the real error behind a tokens-file read or default params. Match the store’s not-found error only, and share this probe withloadso both paths stay aligned.🤖 Prompt for AI Agents
Source: Coding guidelines