Skip to content
Snippets Groups Projects
Commit d15068f4 authored by Markus Alexander Kuppe's avatar Markus Alexander Kuppe
Browse files

[Bugfix] TLCIterator#getLast skips the very last bucket.

Iterate all buckets - even the very last one - when the largest
fingerprint is being looked up.
parent f76c576f
No related branches found
No related tags found
No related merge requests found
...@@ -298,8 +298,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet { ...@@ -298,8 +298,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet {
* ascending order though! * ascending order though!
*/ */
public long getLast(final long lowBound) { public long getLast(final long lowBound) {
int len = buff.length - 1; int len = buff.length;
long[] bucket = buff[len];
// Walk from the end of buff to the beginning. Each bucket that is // Walk from the end of buff to the beginning. Each bucket that is
// found and non-null (null if no fingerprint for such an index has // found and non-null (null if no fingerprint for such an index has
...@@ -308,7 +307,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet { ...@@ -308,7 +307,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet {
// indicates an unoccupied slot, while a negative one corresponds to // indicates an unoccupied slot, while a negative one corresponds to
// a fp that has already been flushed to disk. // a fp that has already been flushed to disk.
while (len > 0) { while (len > 0) {
bucket = buff[--len]; long[] bucket = buff[--len];
// Find last element > 0 in bucket (negative elements have already // Find last element > 0 in bucket (negative elements have already
// been flushed to disk, zero indicates an unoccupied slot). // been flushed to disk, zero indicates an unoccupied slot).
...@@ -356,8 +355,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet { ...@@ -356,8 +355,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet {
* it might as well be the cutOff. * it might as well be the cutOff.
*/ */
int len = buff.length - 1; int len = buff.length;
long[] bucket = buff[len];
// Walk from the end of buff to the beginning. Each bucket that is // Walk from the end of buff to the beginning. Each bucket that is
// found and non-null (null if no fingerprint for such an index has // found and non-null (null if no fingerprint for such an index has
...@@ -366,7 +364,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet { ...@@ -366,7 +364,7 @@ public class MSBDiskFPSet extends HeapBasedDiskFPSet {
// indicates an unoccupied slot, while a negative one corresponds to // indicates an unoccupied slot, while a negative one corresponds to
// a fp that has already been flushed to disk. // a fp that has already been flushed to disk.
while (len > 0) { while (len > 0) {
bucket = buff[--len]; long[] bucket = buff[--len];
// Find last element > 0 in bucket (negative elements have already // Find last element > 0 in bucket (negative elements have already
// been flushed to disk, zero indicates an unoccupied slot). // been flushed to disk, zero indicates an unoccupied slot).
......
...@@ -62,6 +62,24 @@ public class MSBDiskFPSetTest2 extends AbstractHeapBasedDiskFPSetTest { ...@@ -62,6 +62,24 @@ public class MSBDiskFPSetTest2 extends AbstractHeapBasedDiskFPSetTest {
fail(); fail();
} }
public void testHighFingerprint1() throws RemoteException, IOException {
final MSBDiskFPSet msbDiskFPSet = getMSBDiskFPSet();
assertFalse(msbDiskFPSet.put(9223368718049406096L));
msbDiskFPSet.flusher.flushTable();
assertTrue(msbDiskFPSet.put(9223368718049406096L));
msbDiskFPSet.flusher.flushTable();
assertTrue(msbDiskFPSet.put(9223368718049406096L));
}
public void testHighFingerprint2() throws RemoteException, IOException {
final MSBDiskFPSet msbDiskFPSet = getMSBDiskFPSet();
assertFalse(msbDiskFPSet.put(9223335424116589377L));
msbDiskFPSet.flusher.flushTable();
assertTrue(msbDiskFPSet.put(9223335424116589377L));
msbDiskFPSet.flusher.flushTable();
assertTrue(msbDiskFPSet.put(9223335424116589377L));
}
/* /*
* Try to get the last element with no elements in the set. * Try to get the last element with no elements in the set.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment