Search in sources :

Example 11 with PageSwapper

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

the class SingleFilePageSwapperTest method swappingInMustFillPageWithData.

@Test
public void swappingInMustFillPageWithData() throws Exception {
    byte[] bytes = new byte[] { 1, 2, 3, 4 };
    StoreChannel channel = getFs().create(getFile());
    channel.writeAll(wrap(bytes));
    channel.close();
    PageSwapperFactory factory = createSwapperFactory();
    PageSwapper swapper = createSwapper(factory, getFile(), 4, null, false);
    ByteBuffer target = ByteBuffer.allocateDirect(4);
    ByteBufferPage page = new ByteBufferPage(target);
    swapper.read(0, page);
    assertThat(array(target), byteArray(bytes));
}
Also used : PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) StoreChannel(org.neo4j.io.fs.StoreChannel) DelegatingStoreChannel(org.neo4j.graphdb.mockfs.DelegatingStoreChannel) PageSwapper(org.neo4j.io.pagecache.PageSwapper) ByteBuffer(java.nio.ByteBuffer) PageSwapperTest(org.neo4j.io.pagecache.PageSwapperTest) Test(org.junit.Test)

Aggregations

PageSwapper (org.neo4j.io.pagecache.PageSwapper)11 Test (org.junit.Test)10 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)10 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)10 File (java.io.File)6 DelegatingStoreChannel (org.neo4j.graphdb.mockfs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 RandomAdversary (org.neo4j.adversaries.RandomAdversary)4 AdversarialFileSystemAbstraction (org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction)4 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2