Search in sources :

Example 1 with BatchingIdSequence

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;
            }
        }
    }
}
Also used : BatchingIdSequence(org.neo4j.unsafe.impl.batchimport.store.BatchingIdSequence) PagedFile(org.neo4j.io.pagecache.PagedFile) IntStoreHeader(org.neo4j.kernel.impl.store.IntStoreHeader) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File)

Aggregations

File (java.io.File)1 PagedFile (org.neo4j.io.pagecache.PagedFile)1 IntStoreHeader (org.neo4j.kernel.impl.store.IntStoreHeader)1 BatchingIdSequence (org.neo4j.unsafe.impl.batchimport.store.BatchingIdSequence)1