use of jetbrains.exodus.tree.TreeMetaInfo in project xodus by JetBrains.
the class ReadWriteTransaction method doCommit.
Iterable<ExpiredLoggableInfo>[] doCommit(@NotNull final MetaTree.Proto[] out) {
final Set<Map.Entry<Integer, ITreeMutable>> entries = mutableTrees.entrySet();
final Set<Map.Entry<Long, Pair<String, ITree>>> removedEntries = removedStores.entrySet();
final int size = entries.size() + removedEntries.size();
// noinspection unchecked
final Iterable<ExpiredLoggableInfo>[] expiredLoggables = new Iterable[size + 1];
int i = 0;
final ITreeMutable metaTreeMutable = getMetaTree().tree.getMutableCopy();
for (final Map.Entry<Long, Pair<String, ITree>> entry : removedEntries) {
final Pair<String, ITree> value = entry.getValue();
MetaTree.removeStore(metaTreeMutable, value.getFirst(), entry.getKey());
expiredLoggables[i++] = TreeMetaInfo.getTreeLoggables(value.getSecond());
}
removedStores.clear();
for (final Map.Entry<String, TreeMetaInfo> entry : createdStores.entrySet()) {
MetaTree.addStore(metaTreeMutable, entry.getKey(), entry.getValue());
}
createdStores.clear();
final Collection<ExpiredLoggableInfo> last;
for (final Map.Entry<Integer, ITreeMutable> entry : entries) {
final ITreeMutable treeMutable = entry.getValue();
expiredLoggables[i++] = treeMutable.getExpiredLoggables();
MetaTree.saveTree(metaTreeMutable, treeMutable);
}
clearImmutableTrees();
mutableTrees.clear();
expiredLoggables[i] = last = metaTreeMutable.getExpiredLoggables();
out[0] = MetaTree.saveMetaTree(metaTreeMutable, getEnvironment(), last);
return expiredLoggables;
}
use of jetbrains.exodus.tree.TreeMetaInfo in project xodus by JetBrains.
the class ReadWriteTransaction method getTreeMetaInfo.
@Nullable
@Override
TreeMetaInfo getTreeMetaInfo(@NotNull final String name) {
checkIsFinished();
final TreeMetaInfo result = createdStores.get(name);
return result == null ? super.getTreeMetaInfo(name) : result;
}
use of jetbrains.exodus.tree.TreeMetaInfo in project xodus by JetBrains.
the class EnvironmentImpl method openStore.
@Override
@Nullable
public StoreImpl openStore(@NotNull final String name, @NotNull final StoreConfig config, @NotNull final Transaction transaction, final boolean creationRequired) {
final TransactionBase txn = (TransactionBase) transaction;
final TreeMetaInfo metaInfo = txn.getTreeMetaInfo(name);
if (metaInfo == null && !creationRequired) {
return null;
}
return openStoreImpl(name, config, txn, metaInfo);
}
use of jetbrains.exodus.tree.TreeMetaInfo in project xodus by JetBrains.
the class EnvironmentImpl method truncateStore.
@Override
public void truncateStore(@NotNull final String storeName, @NotNull final Transaction txn) {
final ReadWriteTransaction t = throwIfReadonly(txn, "Can't truncate a store in read-only transaction");
StoreImpl store = openStore(storeName, StoreConfig.USE_EXISTING, t, false);
if (store == null) {
throw new ExodusException("Attempt to truncate unknown store '" + storeName + '\'');
}
t.storeRemoved(store);
final TreeMetaInfo metaInfoCloned = store.getMetaInfo().clone(allocateStructureId());
store = new StoreImpl(this, storeName, metaInfoCloned);
t.storeCreated(store);
}
use of jetbrains.exodus.tree.TreeMetaInfo in project xodus by JetBrains.
the class ReadWriteTransaction method doCommit.
ExpiredLoggableCollection doCommit(@NotNull final MetaTreeImpl.Proto[] out) {
final Set<Map.Entry<Integer, ITreeMutable>> entries = mutableTrees.entrySet();
final Set<Map.Entry<Long, Pair<String, ITree>>> removedEntries = removedStores.entrySet();
ExpiredLoggableCollection expiredLoggables = ExpiredLoggableCollection.getEMPTY();
final ITreeMutable metaTreeMutable = getMetaTree().tree.getMutableCopy();
for (final Map.Entry<Long, Pair<String, ITree>> entry : removedEntries) {
final Pair<String, ITree> value = entry.getValue();
MetaTreeImpl.removeStore(metaTreeMutable, value.getFirst(), entry.getKey());
expiredLoggables = expiredLoggables.mergeWith(TreeMetaInfo.getTreeLoggables(value.getSecond()).trimToSize());
}
removedStores.clear();
for (final Map.Entry<String, TreeMetaInfo> entry : createdStores.entrySet()) {
MetaTreeImpl.addStore(metaTreeMutable, entry.getKey(), entry.getValue());
}
createdStores.clear();
for (final Map.Entry<Integer, ITreeMutable> entry : entries) {
final ITreeMutable treeMutable = entry.getValue();
expiredLoggables = expiredLoggables.mergeWith(treeMutable.getExpiredLoggables().trimToSize());
MetaTreeImpl.saveTree(metaTreeMutable, treeMutable);
}
clearImmutableTrees();
mutableTrees.clear();
expiredLoggables = expiredLoggables.mergeWith(metaTreeMutable.getExpiredLoggables().trimToSize());
out[0] = MetaTreeImpl.saveMetaTree(metaTreeMutable, getEnvironment(), expiredLoggables);
return expiredLoggables;
}
Aggregations