*/
long[] values = {60, 80, 40, 50, 0, 20, 10, 70, 30, 90};
int[] ids = {7, 80, 81, 200, 235, 490, 601, 698, 888, 965};
index = fillIndex(values, ids);
for (int i = 0; i < values.length; i++) {
IntSet lookupResult = index.lookup(Bytes.toBytes(values[i]));
Assert.assertEquals(1, lookupResult.size());
Assert.assertEquals(true, lookupResult.contains(ids[i]));
}
Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());
/**
* All the entries have the samae value
*/
values = new long[]{100, 100, 100, 100, 100, 100, 100, 100, 100, 100};
index = fillIndex(values, ids);
IntSet lookupResult = index.lookup(Bytes.toBytes(100L));
Assert.assertEquals(10, lookupResult.size());
for (int id : ids) {
Assert.assertEquals(true, lookupResult.contains(id));
}
Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());
/**
* Some of the entries have one value on the others have another value
*/
values = new long[]{100, 99, 50, 99, 100, 50, 100, 100, 99, 99};
index = fillIndex(values, ids);
lookupResult = index.lookup(Bytes.toBytes(100L));
Assert.assertEquals(4, lookupResult.size());
for (int id : new int[]{7, 235, 601, 698}) {
Assert.assertEquals(true, lookupResult.contains(id));
}
lookupResult = index.lookup(Bytes.toBytes(99L));
Assert.assertEquals(4, lookupResult.size());
for (int id : new int[]{80, 200, 888, 965}) {
Assert.assertEquals(true, lookupResult.contains(id));
}
lookupResult = index.lookup(Bytes.toBytes(50L));
Assert.assertEquals(2, lookupResult.size());
for (int id : new int[]{81, 490}) {
Assert.assertEquals(true, lookupResult.contains(id));
}
Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());
}