use of io.questdb.cairo.vm.api.MemoryCMARW in project questdb by bluestreak01.
the class BinarySearchTest method testFindForwardBeforeRange.
@Test
public void testFindForwardBeforeRange() throws Exception {
assertMemoryLeak(() -> {
try (Path path = new Path()) {
path.of(root).concat("binsearch.d").$();
try (MemoryCMARW appendMem = Vm.getSmallCMARWInstance(FilesFacadeImpl.INSTANCE, path, MemoryTag.MMAP_DEFAULT)) {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 3; j++) {
appendMem.putLong(i);
}
}
long max = 100 * 3 - 1;
try (MemoryMR mem = Vm.getMRInstance(FilesFacadeImpl.INSTANCE, path, 400 * Long.BYTES, MemoryTag.MMAP_DEFAULT)) {
long index = BinarySearch.find(mem, -20, 0, max, BinarySearch.SCAN_DOWN);
Assert.assertEquals(-1, index);
}
}
}
});
}
Aggregations