changeset 115:48c612aff71c

Two small fixes: Former me was actually correct
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 24 Dec 2016 20:58:35 +0000
parents 8944889f75bd
children 02b8cf7b62e5
files src/filter_block.rs src/table_builder.rs
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/filter_block.rs	Sat Dec 24 18:09:27 2016 +0000
+++ b/src/filter_block.rs	Sat Dec 24 20:58:35 2016 +0000
@@ -139,6 +139,10 @@
     /// blk_offset is the offset of the block containing key. Returns whether the key matches the
     /// filter for the block at blk_offset.
     pub fn key_may_match(&self, blk_offset: usize, key: &[u8]) -> bool {
+        if get_filter_index(blk_offset, self.filter_base_lg2) > self.num() {
+            return true
+        }
+
         let filter_begin = self.offset_of(get_filter_index(blk_offset, self.filter_base_lg2));
         let filter_end = self.offset_of(get_filter_index(blk_offset, self.filter_base_lg2) + 1);
 
@@ -178,6 +182,7 @@
 
         // second block
         bld.start_block(5000);
+
         for k in keys.iter() {
             bld.add_key(k);
         }
--- a/src/table_builder.rs	Sat Dec 24 18:09:27 2016 +0000
+++ b/src/table_builder.rs	Sat Dec 24 20:58:35 2016 +0000
@@ -202,12 +202,11 @@
 
         let ctype = self.o.compression_type;
 
-        // Use offset of block that the keys are in.
+        self.write_block(contents, ctype);
+
         if let Some(ref mut fblock) = self.filter_block {
             fblock.start_block(self.offset);
         }
-
-        self.write_block(contents, ctype);
     }
 
     /// Calculates the checksum, writes the block to disk and updates the offset.