Search in sources :

Example 1 with BTreeBalancePolicy

use of jetbrains.exodus.tree.btree.BTreeBalancePolicy in project xodus by JetBrains.

the class StoreImpl method openImmutableTree.

ITree openImmutableTree(@NotNull final MetaTree metaTree) {
    final int structureId = getStructureId();
    final long upToDateRootAddress = metaTree.getRootAddress(structureId);
    final boolean hasDuplicates = metaInfo.hasDuplicates();
    final boolean treeIsEmpty = upToDateRootAddress == Loggable.NULL_ADDRESS;
    final Log log = environment.getLog();
    final ITree result;
    if (!metaInfo.isKeyPrefixing()) {
        final BTreeBalancePolicy balancePolicy = environment.getBTreeBalancePolicy();
        result = treeIsEmpty ? new BTreeEmpty(log, balancePolicy, hasDuplicates, structureId) : new BTree(log, balancePolicy, upToDateRootAddress, hasDuplicates, structureId);
    } else {
        if (treeIsEmpty) {
            result = new PatriciaTreeEmpty(log, structureId, hasDuplicates);
        } else {
            result = hasDuplicates ? new PatriciaTreeWithDuplicates(log, upToDateRootAddress, structureId) : new PatriciaTree(log, upToDateRootAddress, structureId);
        }
    }
    return result;
}
Also used : PatriciaTree(jetbrains.exodus.tree.patricia.PatriciaTree) BTreeBalancePolicy(jetbrains.exodus.tree.btree.BTreeBalancePolicy) Log(jetbrains.exodus.log.Log) BTree(jetbrains.exodus.tree.btree.BTree) BTreeEmpty(jetbrains.exodus.tree.btree.BTreeEmpty) ITree(jetbrains.exodus.tree.ITree) PatriciaTreeEmpty(jetbrains.exodus.tree.patricia.PatriciaTreeEmpty) PatriciaTreeWithDuplicates(jetbrains.exodus.tree.patricia.PatriciaTreeWithDuplicates)

Example 2 with BTreeBalancePolicy

use of jetbrains.exodus.tree.btree.BTreeBalancePolicy in project xodus by JetBrains.

the class StoreImpl method openImmutableTree.

ITree openImmutableTree(@NotNull final MetaTreeImpl metaTree) {
    final int structureId = getStructureId();
    final long upToDateRootAddress = metaTree.getRootAddress(structureId);
    final boolean hasDuplicates = metaInfo.hasDuplicates();
    final boolean treeIsEmpty = upToDateRootAddress == Loggable.NULL_ADDRESS;
    final Log log = environment.getLog();
    final ITree result;
    if (!metaInfo.isKeyPrefixing()) {
        final BTreeBalancePolicy balancePolicy = environment.getBTreeBalancePolicy();
        result = treeIsEmpty ? new BTreeEmpty(log, balancePolicy, hasDuplicates, structureId) : new BTree(log, balancePolicy, upToDateRootAddress, hasDuplicates, structureId);
    } else {
        if (treeIsEmpty) {
            result = new PatriciaTreeEmpty(log, structureId, hasDuplicates);
        } else {
            result = hasDuplicates ? new PatriciaTreeWithDuplicates(log, upToDateRootAddress, structureId) : new PatriciaTree(log, upToDateRootAddress, structureId);
        }
    }
    return result;
}
Also used : PatriciaTree(jetbrains.exodus.tree.patricia.PatriciaTree) BTreeBalancePolicy(jetbrains.exodus.tree.btree.BTreeBalancePolicy) Log(jetbrains.exodus.log.Log) BTree(jetbrains.exodus.tree.btree.BTree) BTreeEmpty(jetbrains.exodus.tree.btree.BTreeEmpty) ITree(jetbrains.exodus.tree.ITree) PatriciaTreeEmpty(jetbrains.exodus.tree.patricia.PatriciaTreeEmpty) PatriciaTreeWithDuplicates(jetbrains.exodus.tree.patricia.PatriciaTreeWithDuplicates)

Example 3 with BTreeBalancePolicy

use of jetbrains.exodus.tree.btree.BTreeBalancePolicy in project xodus by JetBrains.

the class EnvironmentTest method testUpdateBalancePolicy.

@Test
public void testUpdateBalancePolicy() {
    EnvironmentConfig envConfig = env.getEnvironmentConfig();
    final BTreeBalancePolicy bs = env.getBTreeBalancePolicy();
    final ArrayByteIterable wtf = StringBinding.stringToEntry("wtf");
    final int count = bs.getPageMaxSize() - 1;
    {
        final Transaction txn = env.beginTransaction();
        try {
            final Store store = env.openStore("store", StoreConfig.WITHOUT_DUPLICATES, txn);
            for (int i = 0; i < count; ++i) {
                store.put(txn, IntegerBinding.intToEntry(i), wtf);
            }
        } finally {
            txn.commit();
        }
    }
    env.close();
    env = newEnvironmentInstance(LogConfig.create(reader, writer), envConfig.setTreeMaxPageSize(count / 2));
    final Transaction txn = env.beginTransaction();
    try {
        Store store = env.openStore("store", StoreConfig.WITHOUT_DUPLICATES, txn);
        store.put(txn, IntegerBinding.intToEntry(count), wtf);
    } finally {
        txn.commit();
    }
}
Also used : BTreeBalancePolicy(jetbrains.exodus.tree.btree.BTreeBalancePolicy) Test(org.junit.Test)

Aggregations

BTreeBalancePolicy (jetbrains.exodus.tree.btree.BTreeBalancePolicy)3 Log (jetbrains.exodus.log.Log)2 ITree (jetbrains.exodus.tree.ITree)2 BTree (jetbrains.exodus.tree.btree.BTree)2 BTreeEmpty (jetbrains.exodus.tree.btree.BTreeEmpty)2 PatriciaTree (jetbrains.exodus.tree.patricia.PatriciaTree)2 PatriciaTreeEmpty (jetbrains.exodus.tree.patricia.PatriciaTreeEmpty)2 PatriciaTreeWithDuplicates (jetbrains.exodus.tree.patricia.PatriciaTreeWithDuplicates)2 Test (org.junit.Test)1