-
Notifications
You must be signed in to change notification settings - Fork 61
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
Force value-only iteration in the public API #192
Changes from 1 commit
26a6141
9697f4d
5b1f3e2
1e26f77
9456f2c
889a08c
3596edd
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
use crate::{ | ||
btree::{commit_overlay::BTreeChangeSet, BTreeIterator, BTreeTable}, | ||
column::{hash_key, ColId, Column, IterState, ReindexBatch}, | ||
column::{hash_key, ColId, Column, IterState, ReindexBatch, ValueIterState}, | ||
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. Shoudn't we make 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. Good point, even though public types from private modules are allowed to be leaked. They can be used but can't be named. I've aded it to public exports anyway. |
||
error::{try_io, Error, Result}, | ||
hash::IdentityBuildHasher, | ||
index::PlanOutcome, | ||
|
@@ -853,9 +853,16 @@ impl DbInner { | |
} | ||
} | ||
|
||
fn iter_column_while(&self, c: ColId, f: impl FnMut(IterState) -> bool) -> Result<()> { | ||
fn iter_column_while(&self, c: ColId, f: impl FnMut(ValueIterState) -> bool) -> Result<()> { | ||
match &self.columns[c as usize] { | ||
Column::Hash(column) => column.iter_while(&self.log, f), | ||
Column::Hash(column) => column.iter_values(&self.log, f), | ||
Column::Tree(_) => unimplemented!(), | ||
} | ||
} | ||
|
||
fn iter_column_index_while(&self, c: ColId, f: impl FnMut(IterState) -> bool) -> Result<()> { | ||
match &self.columns[c as usize] { | ||
Column::Hash(column) => column.iter_index(&self.log, f), | ||
Column::Tree(_) => unimplemented!(), | ||
} | ||
} | ||
|
@@ -987,12 +994,23 @@ impl Db { | |
self.inner.columns.len() as u8 | ||
} | ||
|
||
/// Iterate a column and call a function for each value. This is only supported for columns with | ||
/// `btree_index` set to `false`. Iteration order is unspecified. | ||
/// Unlike `get` the iteration may not include changes made in recent `commit` calls. | ||
pub fn iter_column_while(&self, c: ColId, f: impl FnMut(ValueIterState) -> bool) -> Result<()> { | ||
self.inner.iter_column_while(c, f) | ||
} | ||
|
||
/// Iterate a column and call a function for each value. This is only supported for columns with | ||
/// `btree_index` set to `false`. Iteration order is unspecified. Note that the | ||
/// `key` field in the state is the hash of the original key. | ||
/// Unlinke `get` the iteration may not include changes made in recent `commit` calls. | ||
pub fn iter_column_while(&self, c: ColId, f: impl FnMut(IterState) -> bool) -> Result<()> { | ||
self.inner.iter_column_while(c, f) | ||
/// Unlike `get` the iteration may not include changes made in recent `commit` calls. | ||
pub fn iter_column_index_while( | ||
&self, | ||
c: ColId, | ||
f: impl FnMut(IterState) -> bool, | ||
) -> Result<()> { | ||
self.inner.iter_column_index_while(c, f) | ||
} | ||
|
||
fn commit_worker(db: Arc<DbInner>) -> Result<()> { | ||
|
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.
Nit: Might be just
for table in &tables.value
. I believetables.value
is a vec