// TODO(csuter): This should run as a different task.
// TODO(csuter): We should provide a way for the caller to skip compactions if there's nothing
// to compact.
/// Writes the items yielded by the iterator into the supplied object and then switches the tree
/// to use the new layer.
This should run as a different task.
TODO(csuter): We should provide a way for the caller to skip compactions if there's nothing
to compact.
Writes the items yielded by the iterator into the supplied object and then switches the tree
to use the new layer.
This should run as a different task . TODO ( csuter ) : We should provide a way for the caller to skip compactions if there ' s nothing to compact . Writes the items yielded by the iterator into the supplied object and then switches the tree to use the new layer .
pub async fn compact_with_iterator(
        &self,
        mut iterator: impl LayerIterator<K, V>,
        mut object_handle: impl ObjectHandle + 'static,
    ) -> Result<(), Error> {
        {
            let mut writer = SimplePersistentLayerWriter::new(
                &mut object_handle,
                SIMPLE_PERSISTENT_LAYER_BLOCK_SIZE,
            );
            while let Some(item_ref) = iterator.get() {
                log::debug!("compact: writing {:?}", item_ref);
                writer.write(item_ref).await?;
                iterator.advance().await?;
            }
            writer.flush().await?;
        }
        self.set_layers(Box::new([object_handle])).await
    }
pub async fn compact_with_iterator ( & self , mut iterator : impl LayerIterator < K , V > , mut object_handle : impl ObjectHandle + ' static , ) -> Result < ( ) , Error > { { let mut writer = SimplePersistentLayerWriter :: new ( & mut object_handle , SIMPLE_PERSISTENT_LAYER_BLOCK_SIZE , ) ; while let Some ( item_ref ) = iterator . get ( ) { log :: debug ! ( " " item_ref ) ; writer . write ( item_ref ) . await ? ; iterator . advance ( ) . await ? ; } writer . flush ( ) . await ? ; } self . set_layers ( Box :: new ( [ object_handle ] ) ) . await }
TODO(csuter): This should run as a different task.
TODO ( csuter ) : This should run as a different task .
&self
iterator
impl LayerIterator<K, V>
object_handle
impl ObjectHandle + 'static