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;
}
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;
}
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();
}
}
Aggregations