changeset 184:b3da8e0fe92d

Add a few comments and remove one unneeded import in table_cache.
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 18 Aug 2017 06:18:25 +0000
parents 98bfd5147ded
children 89e7e8629ba5
files src/block.rs src/table_cache.rs
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/block.rs	Sat Aug 12 17:11:09 2017 +0200
+++ b/src/block.rs	Fri Aug 18 06:18:25 2017 +0000
@@ -10,6 +10,10 @@
 
 pub type BlockContents = Vec<u8>;
 
+/// A Block is an immutable ordered set of key/value entries.
+///
+/// The structure internally looks like follows:
+///
 /// A block is a list of ENTRIES followed by a list of RESTARTS, terminated by a fixed u32
 /// N_RESTARTS.
 ///
@@ -35,7 +39,7 @@
 impl Block {
     /// Return an iterator over this block.
     /// Note that the iterator isn't bound to the block's lifetime; the iterator uses the same
-    /// refcounted block contents as this block. (meaning also that if the iterator isn't released,
+    /// refcounted block contents as this block, meaning that if the iterator isn't released,
     /// the memory occupied by the block isn't, either)
     pub fn iter(&self) -> BlockIter {
         let restarts = u32::decode_fixed(&self.block[self.block.len() - 4..]);
@@ -68,6 +72,8 @@
     }
 }
 
+/// BlockIter is an iterator over the entries in a block. It doesn't depend on the Block's
+/// lifetime, as it uses a refcounted block underneath.
 pub struct BlockIter {
     /// The underlying block contents.
     /// TODO: Maybe (probably...) this needs an Arc.
@@ -398,6 +404,7 @@
 mod tests {
     use super::*;
     use options::*;
+    use types::LdbIterator;
 
     fn get_data() -> Vec<(&'static [u8], &'static [u8])> {
         vec![("key1".as_bytes(), "value1".as_bytes()),
--- a/src/table_cache.rs	Sat Aug 12 17:11:09 2017 +0200
+++ b/src/table_cache.rs	Fri Aug 18 06:18:25 2017 +0000
@@ -1,6 +1,8 @@
+//! table_cache implements a cache providing access to the immutable SSTables on disk. It's a
+//! read-through cache, meaning that non-present tables are read from disk and cached before being
+//! returned.
 
 use cache::{self, Cache};
-use env::RandomAccess;
 use error::Result;
 use options::Options;
 use table_reader::Table;