Search in sources :

Example 1 with JumpingFileChannel

use of org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel in project neo4j by neo4j.

the class TestJumpingIdGenerator method testOffsettedFileChannel.

@Test
public void testOffsettedFileChannel() throws Exception {
    try (JumpingFileSystemAbstraction offsettedFileSystem = new JumpingFileSystemAbstraction(10)) {
        File fileName = new File("target/var/neostore.nodestore.db");
        offsettedFileSystem.deleteFile(fileName);
        offsettedFileSystem.mkdirs(fileName.getParentFile());
        IdGenerator idGenerator = new JumpingIdGeneratorFactory(10).get(IdType.NODE);
        try (JumpingFileChannel channel = (JumpingFileChannel) offsettedFileSystem.open(fileName, "rw")) {
            for (int i = 0; i < 16; i++) {
                writeSomethingLikeNodeRecord(channel, idGenerator.nextId(), i);
            }
        }
        try (JumpingFileChannel channel = (JumpingFileChannel) offsettedFileSystem.open(fileName, "rw")) {
            idGenerator = new JumpingIdGeneratorFactory(10).get(IdType.NODE);
            for (int i = 0; i < 16; i++) {
                assertEquals(i, readSomethingLikeNodeRecord(channel, idGenerator.nextId()));
            }
        }
    }
}
Also used : JumpingFileChannel(org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel) IdGenerator(org.neo4j.kernel.impl.store.id.IdGenerator) File(java.io.File) Test(org.junit.Test)

Example 2 with JumpingFileChannel

use of org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel in project graphdb by neo4j-attic.

the class TestJumpingIdGenerator method testOffsettedFileChannel.

@Test
public void testOffsettedFileChannel() throws Exception {
    String fileName = "target/var/neostore.nodestore.db";
    deleteFileOrDirectory(fileName);
    FileSystemAbstraction offsettedFileSystem = new JumpingFileSystemAbstraction(10);
    IdGenerator idGenerator = new JumpingIdGeneratorFactory(10).get(IdType.NODE);
    JumpingFileChannel channel = (JumpingFileChannel) offsettedFileSystem.open(fileName, "rw");
    for (int i = 0; i < 16; i++) {
        writeSomethingLikeNodeRecord(channel, idGenerator.nextId(), i);
    }
    channel.close();
    channel = (JumpingFileChannel) offsettedFileSystem.open(fileName, "rw");
    idGenerator = new JumpingIdGeneratorFactory(10).get(IdType.NODE);
    for (int i = 0; i < 16; i++) {
        assertEquals(i, readSomethingLikeNodeRecord(channel, idGenerator.nextId()));
    }
    channel.close();
}
Also used : FileSystemAbstraction(org.neo4j.kernel.impl.nioneo.store.FileSystemAbstraction) JumpingFileChannel(org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel) IdGenerator(org.neo4j.kernel.impl.nioneo.store.IdGenerator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 JumpingFileChannel (org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel)2 File (java.io.File)1 FileSystemAbstraction (org.neo4j.kernel.impl.nioneo.store.FileSystemAbstraction)1 IdGenerator (org.neo4j.kernel.impl.nioneo.store.IdGenerator)1 IdGenerator (org.neo4j.kernel.impl.store.id.IdGenerator)1