Search in sources :

Example 81 with ByteIterable

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;
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) Nullable(org.jetbrains.annotations.Nullable)

Example 82 with ByteIterable

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);
        }
    }
}
Also used : Transaction(jetbrains.exodus.env.Transaction) ByteIterable(jetbrains.exodus.ByteIterable)

Example 83 with ByteIterable

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);
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) ByteIterable(jetbrains.exodus.ByteIterable)

Example 84 with ByteIterable

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");
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable)

Example 85 with ByteIterable

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);
    }
}
Also used : Exchange(com.persistit.Exchange) ByteIterable(jetbrains.exodus.ByteIterable) TokyoCabinetBenchmark(jetbrains.exodus.benchmark.TokyoCabinetBenchmark)

Aggregations

ByteIterable (jetbrains.exodus.ByteIterable)93 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)47 Test (org.junit.Test)26 CompressedUnsignedLongByteIterable (jetbrains.exodus.log.CompressedUnsignedLongByteIterable)16 Nullable (org.jetbrains.annotations.Nullable)11 Cursor (jetbrains.exodus.env.Cursor)8 ITreeCursor (jetbrains.exodus.tree.ITreeCursor)8 RandomAccessLoggable (jetbrains.exodus.log.RandomAccessLoggable)7 CompoundByteIterable (jetbrains.exodus.CompoundByteIterable)6 Store (jetbrains.exodus.env.Store)4 TreeSet (java.util.TreeSet)3 TokyoCabinetBenchmark (jetbrains.exodus.benchmark.TokyoCabinetBenchmark)3 PersistentStoreTransaction (jetbrains.exodus.entitystore.PersistentStoreTransaction)3 Exchange (com.persistit.Exchange)2 ExodusException (jetbrains.exodus.ExodusException)2 Pair (jetbrains.exodus.core.dataStructures.Pair)2 HashSet (jetbrains.exodus.core.dataStructures.hash.HashSet)2 PersistentLongSet (jetbrains.exodus.core.dataStructures.persistent.PersistentLongSet)2 Transaction (jetbrains.exodus.env.Transaction)2 Loggable (jetbrains.exodus.log.Loggable)2