Search in sources :

Example 6 with ITree

use of jetbrains.exodus.tree.ITree in project xodus by JetBrains.

the class BTreeStructureIdTest method assertContains.

private void assertContains(long expectedId, long address) {
    ITree firstImTree = new BTree(log, address, false, 3);
    LongIterator it = firstImTree.addressIterator();
    while (it.hasNext()) Assert.assertEquals(expectedId, log.read(it.next()).getStructureId());
}
Also used : ITree(jetbrains.exodus.tree.ITree) LongIterator(jetbrains.exodus.tree.LongIterator)

Example 7 with ITree

use of jetbrains.exodus.tree.ITree in project xodus by JetBrains.

the class StoreImpl method get.

@Override
@Nullable
public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable key) {
    final TransactionBase tx = (TransactionBase) txn;
    final ITree tree = tx.getTree(this);
    final long treeRootAddress = tree.getRootAddress();
    final StoreGetCache storeGetCache = environment.getStoreGetCache();
    final boolean useStoreGetCache = treeRootAddress != Loggable.NULL_ADDRESS && storeGetCache != null;
    // if neither tree is empty nor mutable and StoreGetCache is on
    if (useStoreGetCache) {
        ByteIterable result = storeGetCache.tryKey(treeRootAddress, key);
        if (result != null) {
            return result == NULL_CACHED_VALUE ? null : result;
        }
        result = tree.get(key);
        storeGetCache.cacheObject(treeRootAddress, key, result == null ? NULL_CACHED_VALUE : new ArrayByteIterable(result));
        return result;
    }
    return tree.get(key);
}
Also used : ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) ITree(jetbrains.exodus.tree.ITree) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ITree (jetbrains.exodus.tree.ITree)7 LongIterator (jetbrains.exodus.tree.LongIterator)2 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)1 ByteIterable (jetbrains.exodus.ByteIterable)1 Pair (jetbrains.exodus.core.dataStructures.Pair)1 LongHashMap (jetbrains.exodus.core.dataStructures.hash.LongHashMap)1 LongHashSet (jetbrains.exodus.core.dataStructures.hash.LongHashSet)1 ExpiredLoggableInfo (jetbrains.exodus.log.ExpiredLoggableInfo)1 Log (jetbrains.exodus.log.Log)1 ITreeMutable (jetbrains.exodus.tree.ITreeMutable)1 TreeMetaInfo (jetbrains.exodus.tree.TreeMetaInfo)1 BTree (jetbrains.exodus.tree.btree.BTree)1 BTreeBalancePolicy (jetbrains.exodus.tree.btree.BTreeBalancePolicy)1 BTreeEmpty (jetbrains.exodus.tree.btree.BTreeEmpty)1 PatriciaTree (jetbrains.exodus.tree.patricia.PatriciaTree)1 PatriciaTreeEmpty (jetbrains.exodus.tree.patricia.PatriciaTreeEmpty)1 PatriciaTreeWithDuplicates (jetbrains.exodus.tree.patricia.PatriciaTreeWithDuplicates)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1