use of jetbrains.exodus.env.Store in project xodus by JetBrains.
the class GarbageCollectorTestInMemory method testTextIndexLike.
private void testTextIndexLike(boolean useExpirationChecker) {
final long started = System.currentTimeMillis();
prepare(useExpirationChecker);
final Transaction txn = env.beginTransaction();
final Store store = env.openStore("store", getStoreConfig(false), txn);
final Store storeDups = env.openStore("storeDups", getStoreConfig(true), txn);
txn.commit();
try {
while (System.currentTimeMillis() - started < TEST_DURATION) {
env.executeInTransaction(new TransactionalExecutable() {
@Override
public void execute(@NotNull final Transaction txn) {
int randomInt = rnd.nextInt() & 0x3fffffff;
final int count = 4 + (randomInt) & 0x1f;
for (int j = 0; j < count; randomInt += ++j) {
final int intKey = randomInt & 0x3fff;
final ArrayByteIterable key = IntegerBinding.intToCompressedEntry(intKey);
final int valueLength = 50 + (randomInt % 100);
store.put(txn, key, new ArrayByteIterable(new byte[valueLength]));
storeDups.put(txn, key, IntegerBinding.intToEntry(randomInt % 32));
}
}
});
Thread.sleep(0);
}
} catch (Throwable t) {
memory.dump(new File(System.getProperty("user.home"), "dump"));
logger.error("User code exception: ", t);
Assert.assertTrue(false);
}
}
use of jetbrains.exodus.env.Store in project pwm by pwm-project.
the class XodusLocalDB method putAll.
@Override
public void putAll(final LocalDB.DB db, final Map<String, String> keyValueMap) throws LocalDBException {
checkStatus(true);
environment.executeInTransaction(transaction -> {
final Store store = getStore(db);
for (final Map.Entry<String, String> entry : keyValueMap.entrySet()) {
final ByteIterable k = bindMachine.keyToEntry(entry.getKey());
final ByteIterable v = bindMachine.valueToEntry(entry.getValue());
store.put(transaction, k, v);
}
});
outputLogExecutor.conditionallyExecuteTask();
}
use of jetbrains.exodus.env.Store in project pwm by pwm-project.
the class XodusLocalDB method get.
@Override
public String get(final LocalDB.DB db, final String key) throws LocalDBException {
checkStatus(false);
return environment.computeInReadonlyTransaction(transaction -> {
final Store store = getStore(db);
final ByteIterable returnValue = store.get(transaction, bindMachine.keyToEntry(key));
if (returnValue != null) {
return bindMachine.entryToValue(returnValue);
}
return null;
});
}
use of jetbrains.exodus.env.Store in project pwm by pwm-project.
the class XodusLocalDB method truncate.
@Override
public void truncate(final LocalDB.DB db) throws LocalDBException {
checkStatus(true);
LOGGER.trace("begin truncate of " + db.toString() + ", size=" + this.size(db));
final Date startDate = new Date();
environment.executeInTransaction(transaction -> {
environment.truncateStore(db.toString(), transaction);
final Store newStoreReference = environment.openStore(db.toString(), StoreConfig.USE_EXISTING, transaction);
cachedStoreObjects.put(db, newStoreReference);
});
LOGGER.trace("completed truncate of " + db.toString() + " (" + TimeDuration.fromCurrent(startDate).asCompactString() + ")" + ", size=" + this.size(db));
}
Aggregations