예제 #1
0
 def __init__(self, sstable: SSTable) -> None:
     self.sstable = sstable
     self._pairs = kv_iter(sstable.path)
     try:
         self.current_pair: Tuple[str, Value] = next(self._pairs)
     except StopIteration:
         self.has_next = False
     else:
         self.has_next = True
예제 #2
0
 def resume(cls, log_path):
     memtable = Memtable()
     # recover the memtable if necessary
     if path.exists(log_path):
         for key, value in kv_iter(log_path):
             if value == TOMBSTONE:
                 memtable.unset(key)
             else:
                 memtable.set(key, value)
         writer = KVWriter(log_path, append=True)
     else:
         writer = KVWriter(log_path)
     return cls(writer), memtable
예제 #3
0
def log() -> List[Tuple[str, str]]:
    """Get the commit log file contents. For debugging purposes."""
    return list(kv_iter(LOG_PATH))
예제 #4
0
def test_merge_correctly_merges_files(files_pre_compaction):
    expected = list(kv_iter(f"{FIXTURES}/segment-0-compacted-expected.dat"))
    merged_file = SSTable.merge(files_pre_compaction)
    result = list(kv_iter(merged_file.path))
    assert result == expected