diff --git a/src/cache/delta_reader.rs b/src/cache/delta_reader.rs index 1b7937a..7b5fbe3 100644 --- a/src/cache/delta_reader.rs +++ b/src/cache/delta_reader.rs @@ -56,6 +56,24 @@ impl DeltaReader { tokio::task::block_in_place(|| self.get(key)) } + /// Get the value of the smallest key written value for given [`Schema`]. + pub fn get_smallest(&self) -> anyhow::Result> { + let mut iterator = self.iter::()?; + if let Some((key, value)) = iterator.next() { + let key = S::Key::decode_key(&key)?; + let value = S::Value::decode_value(&value)?; + return Ok(Some((key, value))); + } + Ok(None) + } + + /// Async version of [`DeltaReader::get_smallest`]. + pub async fn get_smallest_async( + &self, + ) -> anyhow::Result> { + tokio::task::block_in_place(|| self.get_smallest::()) + } + /// Get a value of the largest key written value for given [`Schema`]. pub fn get_largest(&self) -> anyhow::Result> { let mut iterator = self.iter_rev::()?;