Search in sources :

Example 6 with Exchange

use of com.persistit.Exchange in project xodus by JetBrains.

the class JMHPersistItTokyoCabinetReadBenchmark method randomRead.

@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = WARMUP_ITERATIONS)
@Measurement(iterations = MEASUREMENT_ITERATIONS)
@Fork(FORKS)
public void randomRead(final Blackhole bh) throws PersistitException {
    final Exchange exchange = createTestStore();
    for (final ByteIterable key : randomKeys) {
        exchange.clear();
        for (int i = 0; i < key.getLength(); i++) {
            exchange.append(key.getBytesUnsafe()[i]);
        }
        exchange.fetch();
        bh.consume(((byte[]) exchange.getValue().get()).length);
    }
}
Also used : Exchange(com.persistit.Exchange) ByteIterable(jetbrains.exodus.ByteIterable) TokyoCabinetBenchmark(jetbrains.exodus.benchmark.TokyoCabinetBenchmark)

Example 7 with Exchange

use of com.persistit.Exchange in project xodus by JetBrains.

the class JMHPersistItTokyoCabinetReadBenchmark method successiveRead.

@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = WARMUP_ITERATIONS)
@Measurement(iterations = MEASUREMENT_ITERATIONS)
@Fork(FORKS)
public void successiveRead(final Blackhole bh) throws PersistitException {
    final Exchange exchange = createTestStore();
    exchange.clear();
    exchange.append(Key.BEFORE);
    while (exchange.traverse(Key.GT, true)) {
        bh.consume(exchange.getKey().toString().length());
        bh.consume(((byte[]) exchange.getValue().get()).length);
    }
}
Also used : Exchange(com.persistit.Exchange) TokyoCabinetBenchmark(jetbrains.exodus.benchmark.TokyoCabinetBenchmark)

Example 8 with Exchange

use of com.persistit.Exchange in project titan by thinkaurelius.

the class PersistitStoreManager method clearStorage.

@Override
public void clearStorage() throws StorageException {
    for (String key : stores.keySet()) {
        PersistitKeyValueStore store = stores.remove(key);
        store.clear();
    }
    Volume volume;
    String[] treeNames;
    try {
        volume = db.getVolume(VOLUME_NAME);
        treeNames = volume.getTreeNames();
    } catch (PersistitException ex) {
        throw new PermanentStorageException(ex);
    }
    for (String treeName : treeNames) {
        try {
            Exchange ex = new Exchange(db, volume, treeName, false);
            ex.removeTree();
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        }
    }
    close();
    IOUtils.deleteFromDirectory(directory);
}
Also used : Exchange(com.persistit.Exchange) Volume(com.persistit.Volume) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Aggregations

Exchange (com.persistit.Exchange)8 PersistitException (com.persistit.exception.PersistitException)5 TokyoCabinetBenchmark (jetbrains.exodus.benchmark.TokyoCabinetBenchmark)3 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)2 NoSuchElementException (java.util.NoSuchElementException)2 ByteIterable (jetbrains.exodus.ByteIterable)2 Volume (com.persistit.Volume)1