use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PersistentSequentialDictionary method getOrAllocateId.
public int getOrAllocateId(@NotNull final TxnProvider txnProvider, @NotNull final String name) {
Integer result = cache.get(name);
if (result != null && result >= 0) {
return result;
}
synchronized (lock) {
result = cache.get(name);
if (result != null && result >= 0) {
return result;
}
final ByteIterable nameEntry = StringBinding.stringToEntry(name);
final PersistentStoreTransaction txn = txnProvider.getTransaction();
final ByteIterable idEntry = table.get(txn.getEnvironmentTransaction(), nameEntry);
final int id = idEntry == null ? (int) sequence.increment() : IntegerBinding.compressedEntryToInt(idEntry);
putIdUnsafe(name, id);
if (idEntry == null) {
operationsLog.add(new DictionaryOperation() {
@Override
public void persist(final Transaction txn) {
table.put(txn, nameEntry, IntegerBinding.intToCompressedEntry(id));
}
});
created(txn, id);
}
return id;
}
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class JMHPersistItTokyoCabinetBenchmarkBase method writeSuccessiveKeys.
void writeSuccessiveKeys(@NotNull final Exchange store) throws PersistitException {
for (final ByteIterable key : successiveKeys) {
exchange.clear();
for (int i = 0; i < key.getLength(); i++) {
exchange.append(key.getBytesUnsafe()[i]);
}
exchange.getValue().put(key.getBytesUnsafe());
exchange.store();
}
persistit.flush();
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class JMHPersistItTokyoCabinetWriteBenchmark method randomWrite.
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = WARMUP_ITERATIONS)
@Measurement(iterations = MEASUREMENT_ITERATIONS)
@Fork(FORKS)
public void randomWrite() 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.getValue().put(key.getBytesUnsafe());
exchange.store();
}
persistit.flush();
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PropertyValueIterable method countImpl.
@Override
protected long countImpl(@NotNull final PersistentStoreTransaction txn) {
final ByteIterable key = getStore().getPropertyTypes().dataToPropertyValue(value).dataToEntry();
final Cursor valueIdx = openCursor(txn);
return valueIdx == null ? 0 : new SingleKeyCursorCounter(valueIdx, key).getCount();
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class VfsSettings method get.
ByteIterable get(@Nullable final Transaction txn, @NotNull final String settingName) {
final ArrayByteIterable key = StringBinding.stringToEntry(settingName);
if (txn != null) {
return settingStore.get(txn, key);
}
final ByteIterable[] result = new ByteIterable[1];
env.executeInTransaction(new TransactionalExecutable() {
@Override
public void execute(@NotNull final Transaction txn) {
result[0] = settingStore.get(txn, key);
}
});
return result[0];
}
Aggregations