use of org.neo4j.kernel.impl.store.id.IdGenerator in project neo4j by neo4j.
the class IdGeneratorTest method testChurnIdBatchAtGrabSize.
@Test
public void testChurnIdBatchAtGrabSize() {
IdGenerator idGenerator = null;
try {
IdGeneratorImpl.createGenerator(fs, idGeneratorFile(), 0, false);
final int grabSize = 10, rounds = 10;
idGenerator = new IdGeneratorImpl(fs, idGeneratorFile(), grabSize, 1000, true, 0);
for (int i = 0; i < rounds; i++) {
Set<Long> ids = new HashSet<>();
for (int j = 0; j < grabSize; j++) {
ids.add(idGenerator.nextId());
}
for (Long id : ids) {
idGenerator.freeId(id);
}
}
long newId = idGenerator.nextId();
assertTrue("Expected IDs to be reused (" + grabSize + " at a time). high ID was: " + newId, newId < grabSize * rounds);
} finally {
if (idGenerator != null) {
closeIdGenerator(idGenerator);
}
File file = idGeneratorFile();
if (file.exists()) {
assertTrue(file.delete());
}
}
}
Aggregations