Skip to content

Bulk ingestion API #152

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

Merged
merged 3 commits into from
Mar 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/partition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,28 @@ impl GarbageCollection for PartitionHandle {
}

impl PartitionHandle {
/// Ingests a sorted stream of key-value pairs into the partition.
///
/// Can only be called on a new fresh, empty partition.
///
/// # Errors
///
/// Will return `Err` if an IO error occurs.
///
/// # Panics
///
/// Panics if the partition is **not** initially empty.
///
/// Will panic if the input iterator is not sorted in ascending order.
pub fn ingest<K: Into<UserKey>, V: Into<UserValue>>(
&self,
iter: impl Iterator<Item = (K, V)>,
) -> crate::Result<()> {
self.tree
.ingest(iter.map(|(k, v)| (k.into(), v.into())))
.map_err(Into::into)
}

pub(crate) fn from_keyspace(
keyspace: &Keyspace,
tree: AnyTree,
Expand Down