diff --git a/src/main/java/com/tomfran/lsm/sstable/SSTable.java b/src/main/java/com/tomfran/lsm/sstable/SSTable.java index b00f44e..ce75436 100644 --- a/src/main/java/com/tomfran/lsm/sstable/SSTable.java +++ b/src/main/java/com/tomfran/lsm/sstable/SSTable.java @@ -96,7 +96,7 @@ private void initializeFromDisk(String filename) { int sizeCumulative = 0; sparseSizeCount.add(sizeCumulative); - for (int i = 0; i < sparseSize; i++) { + for (int i = 0; i < sparseSize - 1; i++) { sizeCumulative += indexIs.readVByteInt(); sparseSizeCount.add(sizeCumulative); } diff --git a/src/test/java/com/tomfran/lsm/sstable/SSTableReconstructTest.java b/src/test/java/com/tomfran/lsm/sstable/SSTableReconstructTest.java index f7fc56e..b1acbd0 100644 --- a/src/test/java/com/tomfran/lsm/sstable/SSTableReconstructTest.java +++ b/src/test/java/com/tomfran/lsm/sstable/SSTableReconstructTest.java @@ -51,10 +51,10 @@ void shouldReconstruct() { assert t2.sparseOffsets.size() == t1.sparseOffsets.size(); for (var i = 0; i < t2.sparseOffsets.size(); i++) assert t2.sparseOffsets.getLong(i) == t1.sparseOffsets.getLong(i); -// -// assert t2.sparseKeys.size() == t1.sparseKeys.size() : "keys lenght don't match"; -// for (var i = 0; i < t2.sparseKeys.size(); i++) -// assert compare(t2.sparseKeys.get(i), t1.sparseKeys.get(i)) == 0 : "keys don't match"; + + assert t2.sparseKeys.size() == t1.sparseKeys.size() : "keys lenght don't match"; + for (var i = 0; i < t2.sparseKeys.size(); i++) + assert compare(t2.sparseKeys.get(i), t1.sparseKeys.get(i)) == 0 : "keys don't match"; t2.close(); }