Search in sources :

Example 46 with PageCursor

use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.

the class CompositePageCursorTest method putByteArrayBeyondEndOfViewMustRaiseBoundsFlag.

@Test
public void putByteArrayBeyondEndOfViewMustRaiseBoundsFlag() throws Exception {
    PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
    for (int i = 0; i < 3 * PAGE_SIZE; i++) {
        pageCursor.putBytes(bytes);
    }
    assertTrue(pageCursor.checkAndClearBoundsFlag());
    assertFalse(pageCursor.checkAndClearBoundsFlag());
}
Also used : PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 47 with PageCursor

use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.

the class CompositePageCursorTest method getIntOffsettedBeyondEndOfViewMustRaiseBoundsFlag.

@Test
public void getIntOffsettedBeyondEndOfViewMustRaiseBoundsFlag() throws Exception {
    PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
    for (int i = 0; i < 3 * PAGE_SIZE; i++) {
        pageCursor.getInt(i);
    }
    assertTrue(pageCursor.checkAndClearBoundsFlag());
    assertFalse(pageCursor.checkAndClearBoundsFlag());
}
Also used : PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 48 with PageCursor

use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.

the class CompositePageCursorTest method getLongBeyondEndOfViewMustRaiseBoundsFlag.

@Test
public void getLongBeyondEndOfViewMustRaiseBoundsFlag() throws Exception {
    PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
    for (int i = 0; i < 3 * PAGE_SIZE; i++) {
        pageCursor.getLong();
    }
    assertTrue(pageCursor.checkAndClearBoundsFlag());
    assertFalse(pageCursor.checkAndClearBoundsFlag());
}
Also used : PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 49 with PageCursor

use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.

the class CompositePageCursorTest method retryShouldCheckAndResetBothCursors.

@Test
public void retryShouldCheckAndResetBothCursors() throws Exception {
    PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
    assertFalse(pageCursor.shouldRetry());
    first.setNeedsRetry(true);
    assertTrue(pageCursor.shouldRetry());
    first.setNeedsRetry(false);
    assertFalse(pageCursor.shouldRetry());
    second.setNeedsRetry(true);
    assertTrue(pageCursor.shouldRetry());
}
Also used : PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 50 with PageCursor

use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.

the class CompositePageCursorTest method putBytesMustHitFirstCursorBeforeFlip.

@Test
public void putBytesMustHitFirstCursorBeforeFlip() throws Exception {
    PageCursor c = CompositePageCursor.compose(first, 4, second, 4);
    c.putBytes(new byte[] { 1, 2, 3, 4 });
    c.setOffset(0);
    c.getBytes(bytes);
    assertThat(bytes, byteArray(1, 2, 3, 4));
    assertFalse(c.checkAndClearBoundsFlag());
}
Also used : PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Aggregations

PageCursor (org.neo4j.io.pagecache.PageCursor)184 Test (org.junit.Test)124 StubPageCursor (org.neo4j.io.pagecache.StubPageCursor)106 PagedFile (org.neo4j.io.pagecache.PagedFile)19 IOException (java.io.IOException)12 File (java.io.File)8 CursorException (org.neo4j.io.pagecache.CursorException)6 PageCacheTest (org.neo4j.io.pagecache.PageCacheTest)6 CompositePageCursor (org.neo4j.io.pagecache.impl.CompositePageCursor)6 DelegatingPageCursor (org.neo4j.io.pagecache.impl.DelegatingPageCursor)6 ByteBuffer (java.nio.ByteBuffer)5 DelegatingStoreChannel (org.neo4j.graphdb.mockfs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)4 DelegatingPagedFile (org.neo4j.io.pagecache.DelegatingPagedFile)4 ConfigurablePageCursorTracerSupplier (org.neo4j.io.pagecache.tracing.ConfigurablePageCursorTracerSupplier)4 RecordingPageCacheTracer (org.neo4j.io.pagecache.tracing.recording.RecordingPageCacheTracer)4 Evict (org.neo4j.io.pagecache.tracing.recording.RecordingPageCacheTracer.Evict)4 RecordingPageCursorTracer (org.neo4j.io.pagecache.tracing.recording.RecordingPageCursorTracer)4 Fault (org.neo4j.io.pagecache.tracing.recording.RecordingPageCursorTracer.Fault)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)3