use of org.neo4j.unsafe.impl.batchimport.store.BatchingIdSequence in project neo4j by neo4j.
the class AbstractRecordFormatTest method verifyWriteAndRead.
private <R extends AbstractBaseRecord> void verifyWriteAndRead(Supplier<RecordFormat<R>> formatSupplier, Supplier<Generator<R>> generatorSupplier, Supplier<RecordKey<R>> keySupplier) throws IOException {
// GIVEN
try (PagedFile storeFile = pageCache.map(new File("store-" + name.getMethodName()), PAGE_SIZE, CREATE)) {
RecordFormat<R> format = formatSupplier.get();
RecordKey<R> key = keySupplier.get();
Generator<R> generator = generatorSupplier.get();
int recordSize = format.getRecordSize(new IntStoreHeader(DATA_SIZE));
BatchingIdSequence idSequence = new BatchingIdSequence(random.nextBoolean() ? idSureToBeOnTheNextPage(PAGE_SIZE, recordSize) : 10);
// WHEN
long time = currentTimeMillis();
long endTime = time + TEST_TIME;
long i = 0;
for (; i < TEST_ITERATIONS && currentTimeMillis() < endTime; i++) {
R written = generator.get(recordSize, format, i % 5);
R read = format.newRecord();
try {
writeRecord(written, format, storeFile, recordSize, idSequence);
readAndVerifyRecord(written, read, format, key, storeFile, recordSize);
idSequence.reset();
} catch (Throwable t) {
Exceptions.setMessage(t, t.getMessage() + " : written:" + written + ", read:" + read + ", seed:" + random.seed() + ", iteration:" + i);
throw t;
}
}
}
}
Aggregations