Search in sources :

Example 1 with DelegatingPageCursor

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MutableLong(org.apache.commons.lang3.mutable.MutableLong) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) Test(org.junit.Test)

Example 2 with DelegatingPageCursor

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();
                        }
                    };
                }
            };
        }
    };
}
Also used : OpenOption(java.nio.file.OpenOption) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) PagedFile(org.neo4j.io.pagecache.PagedFile) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) IOException(java.io.IOException) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) Before(org.junit.Before)

Aggregations

PageCursor (org.neo4j.io.pagecache.PageCursor)2 DelegatingPageCursor (org.neo4j.io.pagecache.impl.DelegatingPageCursor)2 File (java.io.File)1 IOException (java.io.IOException)1 OpenOption (java.nio.file.OpenOption)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DelegatingPageCache (org.neo4j.io.pagecache.DelegatingPageCache)1 DelegatingPagedFile (org.neo4j.io.pagecache.DelegatingPagedFile)1 PagedFile (org.neo4j.io.pagecache.PagedFile)1