use of org.neo4j.kernel.impl.nioneo.store.IdGenerator in project graphdb by neo4j-attic.
the class JumpingIdGeneratorFactory method get.
public IdGenerator get(IdType idType) {
if (idType == IdType.NODE || idType == IdType.RELATIONSHIP || idType == IdType.PROPERTY || idType == IdType.STRING_BLOCK || idType == IdType.ARRAY_BLOCK) {
IdGenerator generator = generators.get(idType);
if (generator == null) {
generator = new JumpingIdGenerator();
generators.put(idType, generator);
}
return generator;
}
return forTheRest;
}
use of org.neo4j.kernel.impl.nioneo.store.IdGenerator 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();
}
use of org.neo4j.kernel.impl.nioneo.store.IdGenerator in project graphdb by neo4j-attic.
the class TestJumpingIdGenerator method testIt.
@Test
public void testIt() throws Exception {
int sizePerJump = 1000;
IdGeneratorFactory factory = new JumpingIdGeneratorFactory(sizePerJump);
IdGenerator generator = factory.get(IdType.NODE);
for (int i = 0; i < sizePerJump / 2; i++) {
assertEquals((long) i, generator.nextId());
}
for (int i = 0; i < sizePerJump - 1; i++) {
long expected = 0x100000000L - sizePerJump / 2 + i;
if (expected >= 0xFFFFFFFFL) {
expected++;
}
assertEquals(expected, generator.nextId());
}
for (int i = 0; i < sizePerJump; i++) {
assertEquals(0x200000000L - sizePerJump / 2 + i, generator.nextId());
}
for (int i = 0; i < sizePerJump; i++) {
assertEquals(0x300000000L - sizePerJump / 2 + i, generator.nextId());
}
}
use of org.neo4j.kernel.impl.nioneo.store.IdGenerator in project graphdb by neo4j-attic.
the class MasterImpl method allocateIds.
public Response<IdAllocation> allocateIds(IdType idType) {
IdGenerator generator = graphDbConfig.getIdGeneratorFactory().get(idType);
IdAllocation result = new IdAllocation(generator.nextIdBatch(ID_GRAB_SIZE), generator.getHighId(), generator.getDefragCount());
return MasterUtil.packResponseWithoutTransactionStream(graphDb, SlaveContext.EMPTY, result);
}
Aggregations