-
Notifications
You must be signed in to change notification settings - Fork 453
feat: Incremental append scan #2337
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
Open
xanderbailey
wants to merge
26
commits into
apache:main
Choose a base branch
from
xanderbailey:xb/incremental_read
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9f23bf4
Add incremental reads
xanderbailey bdc43d8
Add datafusion integration
xanderbailey 2bc7162
fmt
xanderbailey 0149ed7
fix tests
xanderbailey c0fd23e
clippy
xanderbailey 16854e2
clippy
xanderbailey b7711c2
fmt
xanderbailey 353b549
tests
xanderbailey 21ef002
current schema
xanderbailey 47c254b
new scan
xanderbailey 1f08192
fixes
xanderbailey b4a5277
remove
xanderbailey a65c13c
refactor
xanderbailey 4a8480f
Remove examples
xanderbailey 931d100
move tests
xanderbailey 5383364
rename
xanderbailey 340ab16
fix
xanderbailey 11c68d7
nit
xanderbailey 11cce80
generify
xanderbailey 251ef92
make java semantics true here
xanderbailey 52f27fc
fix-up
xanderbailey 8d376de
clippy
xanderbailey 0432a63
tests
xanderbailey df037c4
Fix exclusive check
xanderbailey b283456
fmt
xanderbailey 3a4f875
don't need this
xanderbailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,14 @@ use crate::spec::{ | |
| }; | ||
| use crate::{Error, ErrorKind, Result}; | ||
|
|
||
| /// Filter applied to each [`ManifestFile`] before fetching it. | ||
| /// Returns `true` to include the manifest, `false` to skip it. | ||
| pub(crate) type ManifestFileFilter = Arc<dyn Fn(&ManifestFile) -> bool + Send + Sync>; | ||
|
|
||
| /// Filter applied to each manifest entry after loading a manifest. | ||
| /// Returns `true` to include the entry, `false` to skip it. | ||
| pub(crate) type ManifestEntryFilter = Arc<dyn Fn(&ManifestEntryRef) -> bool + Send + Sync>; | ||
|
|
||
| /// Wraps a [`ManifestFile`] alongside the objects that are needed | ||
| /// to process it in a thread-safe manner | ||
| pub(crate) struct ManifestFileContext { | ||
|
|
@@ -47,6 +55,7 @@ pub(crate) struct ManifestFileContext { | |
| expression_evaluator_cache: Arc<ExpressionEvaluatorCache>, | ||
| delete_file_index: DeleteFileIndex, | ||
| case_sensitive: bool, | ||
| entry_filter: Option<ManifestEntryFilter>, | ||
| } | ||
|
|
||
| /// Wraps a [`ManifestEntryRef`] alongside the objects that are needed | ||
|
|
@@ -76,12 +85,19 @@ impl ManifestFileContext { | |
| mut sender, | ||
| expression_evaluator_cache, | ||
| delete_file_index, | ||
| .. | ||
| case_sensitive, | ||
| entry_filter, | ||
| } = self; | ||
|
|
||
| let manifest = object_cache.get_manifest(&manifest_file).await?; | ||
|
|
||
| for manifest_entry in manifest.entries() { | ||
| if let Some(ref filter) = entry_filter | ||
| && !filter(manifest_entry) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| let manifest_entry_context = ManifestEntryContext { | ||
| // TODO: refactor to avoid the expensive ManifestEntry clone | ||
| manifest_entry: manifest_entry.clone(), | ||
|
|
@@ -91,7 +107,7 @@ impl ManifestFileContext { | |
| bound_predicates: bound_predicates.clone(), | ||
| snapshot_schema: snapshot_schema.clone(), | ||
| delete_file_index: delete_file_index.clone(), | ||
| case_sensitive: self.case_sensitive, | ||
| case_sensitive, | ||
| }; | ||
|
|
||
| sender | ||
|
|
@@ -146,7 +162,6 @@ impl ManifestEntryContext { | |
|
|
||
| /// PlanContext wraps a [`SnapshotRef`] alongside all the other | ||
| /// objects that are required to perform a scan file plan. | ||
| #[derive(Debug)] | ||
| pub(crate) struct PlanContext { | ||
| pub snapshot: SnapshotRef, | ||
|
|
||
|
|
@@ -161,6 +176,25 @@ pub(crate) struct PlanContext { | |
| pub partition_filter_cache: Arc<PartitionFilterCache>, | ||
| pub manifest_evaluator_cache: Arc<ManifestEvaluatorCache>, | ||
| pub expression_evaluator_cache: Arc<ExpressionEvaluatorCache>, | ||
| pub manifest_file_filter: Option<ManifestFileFilter>, | ||
| pub manifest_entry_filter: Option<ManifestEntryFilter>, | ||
| } | ||
|
|
||
| impl std::fmt::Debug for PlanContext { | ||
|
Contributor
Author
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.
|
||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| f.debug_struct("PlanContext") | ||
| .field("snapshot", &self.snapshot) | ||
| .field("case_sensitive", &self.case_sensitive) | ||
| .field( | ||
| "manifest_file_filter", | ||
| &self.manifest_file_filter.as_ref().map(|_| "..."), | ||
| ) | ||
| .field( | ||
| "manifest_entry_filter", | ||
| &self.manifest_entry_filter.as_ref().map(|_| "..."), | ||
| ) | ||
| .finish_non_exhaustive() | ||
| } | ||
| } | ||
|
|
||
| impl PlanContext { | ||
|
|
@@ -214,6 +248,12 @@ impl PlanContext { | |
| // TODO: Ideally we could ditch this intermediate Vec as we return an iterator. | ||
| let mut filtered_mfcs = vec![]; | ||
| for manifest_file in manifest_files { | ||
| if let Some(ref filter) = self.manifest_file_filter | ||
| && !filter(manifest_file) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| let tx = if manifest_file.content == ManifestContentType::Deletes { | ||
| delete_file_tx.clone() | ||
| } else { | ||
|
|
@@ -283,6 +323,7 @@ impl PlanContext { | |
| expression_evaluator_cache: self.expression_evaluator_cache.clone(), | ||
| delete_file_index, | ||
| case_sensitive: self.case_sensitive, | ||
| entry_filter: self.manifest_entry_filter.clone(), | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
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.
I think this is a nice way to inject these filters and should extend to other future scans