use of org.neo4j.io.pagecache.impl.DelegatingPageCursor in project neo4j by neo4j.
the class SeekCursorTest method mustNotContinueToSecondLeafAfterFindingEndOfRangeInFirst.
@Test
public void mustNotContinueToSecondLeafAfterFindingEndOfRangeInFirst() throws Exception {
AtomicBoolean nextCalled = new AtomicBoolean();
PageCursor pageCursorSpy = new DelegatingPageCursor(cursor) {
@Override
public boolean next(long pageId) throws IOException {
nextCalled.set(true);
return super.next(pageId);
}
};
// GIVEN
int i = 0;
while (i < maxKeyCount * 2) {
if (i == maxKeyCount) {
createRightSibling(pageCursorSpy);
}
append(i);
i++;
}
int fromInclusive = maxKeyCount * 2 - 1;
int toExclusive = maxKeyCount;
// Reset
nextCalled.set(false);
// WHEN
try (SeekCursor<MutableLong, MutableLong> cursor = seekCursor(fromInclusive, toExclusive, pageCursorSpy)) {
// THEN
assertRangeInSingleLeaf(fromInclusive, toExclusive, cursor);
}
assertFalse("Cursor continued to next leaf even though end of range is within first leaf", nextCalled.get());
}
use of org.neo4j.io.pagecache.impl.DelegatingPageCursor in project neo4j by neo4j.
the class MetaDataStoreTest method setUp.
@Before
public void setUp() {
fs = fsRule.get();
pageCache = pageCacheRule.getPageCache(fs);
fakePageCursorOverflow = false;
pageCacheWithFakeOverflow = new DelegatingPageCache(pageCache) {
@Override
public PagedFile map(File file, int pageSize, OpenOption... openOptions) throws IOException {
return new DelegatingPagedFile(super.map(file, pageSize, openOptions)) {
@Override
public PageCursor io(long pageId, int pf_flags) throws IOException {
return new DelegatingPageCursor(super.io(pageId, pf_flags)) {
@Override
public boolean checkAndClearBoundsFlag() {
return fakePageCursorOverflow | super.checkAndClearBoundsFlag();
}
};
}
};
}
};
}
Aggregations