use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PersistentSequentialDictionary method getName.
@Nullable
public String getName(@NotNull final TxnProvider txnProvider, final int id) {
String result = reverseCache.get(id);
if (result == null) {
synchronized (lock) {
final ByteIterable idEntry = IntegerBinding.intToCompressedEntry(id);
final ByteIterable typeEntry = table.get2(txnProvider.getTransaction().getEnvironmentTransaction(), idEntry);
if (typeEntry != null) {
result = StringBinding.entryToString(typeEntry);
if (result != null) {
reverseCache.put(id, result);
}
}
}
}
return result;
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PersistentSequentialDictionary method rename.
public void rename(@NotNull final PersistentStoreTransaction txn, @NotNull final String oldName, @NotNull final String newName) {
if (oldName.equals(newName)) {
return;
}
final int id = getId(txn, oldName);
if (id < 0) {
throw new IllegalArgumentException("Old entity type doesn't exist: " + oldName);
}
final int newId = getId(txn, newName);
final ByteIterable idEntry = IntegerBinding.intToCompressedEntry(id);
synchronized (lock) {
operationsLog.add(new DictionaryOperation() {
@Override
void persist(final Transaction txn) {
table.delete(txn, StringBinding.stringToEntry(oldName), idEntry);
table.put(txn, StringBinding.stringToEntry(newName), idEntry);
}
});
cache.remove(oldName);
cache.put(newName, id);
reverseCache.remove(id);
if (newId >= 0) {
reverseCache.remove(newId);
}
}
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class PropertiesTable method delete.
public void delete(@NotNull final PersistentStoreTransaction txn, final long localId, @NotNull final ByteIterable value, final int propertyId, @NotNull final ComparableValueType type) {
final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
final Transaction envTxn = txn.getEnvironmentTransaction();
final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
primaryStore.delete(envTxn, key);
deleteFromStore(envTxn, getOrCreateValueIndex(txn, propertyId), secondaryValue, createSecondaryKeys(store.getPropertyTypes(), value, type));
allPropsIndex.remove(envTxn, propertyId, localId);
}
use of jetbrains.exodus.ByteIterable in project xodus by JetBrains.
the class BlobsTable method delete.
public void delete(@NotNull final Transaction txn, final long localId, final int blobId) {
final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId));
boolean success = primaryStore.delete(txn, key) && allBlobsIndex.remove(txn, blobId, localId);
checkStatus(success, "Failed to delete");
}
use of jetbrains.exodus.ByteIterable 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);
}
}
Aggregations