Skip to content

Commit 995d148

Browse files
authored
Merge pull request #152 from fjall-rs/feat/ingestion-api
Bulk ingestion API
2 parents b5a0347 + d32efe4 commit 995d148

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/partition/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,28 @@ impl GarbageCollection for PartitionHandle {
220220
}
221221

222222
impl PartitionHandle {
223+
/// Ingests a sorted stream of key-value pairs into the partition.
224+
///
225+
/// Can only be called on a new fresh, empty partition.
226+
///
227+
/// # Errors
228+
///
229+
/// Will return `Err` if an IO error occurs.
230+
///
231+
/// # Panics
232+
///
233+
/// Panics if the partition is **not** initially empty.
234+
///
235+
/// Will panic if the input iterator is not sorted in ascending order.
236+
pub fn ingest<K: Into<UserKey>, V: Into<UserValue>>(
237+
&self,
238+
iter: impl Iterator<Item = (K, V)>,
239+
) -> crate::Result<()> {
240+
self.tree
241+
.ingest(iter.map(|(k, v)| (k.into(), v.into())))
242+
.map_err(Into::into)
243+
}
244+
223245
pub(crate) fn from_keyspace(
224246
keyspace: &Keyspace,
225247
tree: AnyTree,

0 commit comments

Comments
 (0)