diff --git a/src/partition/mod.rs b/src/partition/mod.rs index 6ce9e57..b9294e9 100644 --- a/src/partition/mod.rs +++ b/src/partition/mod.rs @@ -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, V: Into>( + &self, + iter: impl Iterator, + ) -> 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,