use of com.torodb.core.transaction.metainf.MetaElementState in project torodb by torodb.
the class SnapshotMerger method merge.
@SuppressWarnings("checkstyle:LineLength")
private void merge(MetaDatabase newDb, MetaDatabase oldDb, MutableMetaCollection newStructure, ImmutableMetaCollection oldStructure, ImmutableMetaCollection.Builder parentBuilder, MutableMetaDocPart changed) throws UnmergeableException {
ImmutableMetaDocPart byRef = oldStructure.getMetaDocPartByTableRef(changed.getTableRef());
ImmutableMetaDocPart byId = oldStructure.getMetaDocPartByIdentifier(changed.getIdentifier());
if (byRef != byId) {
throw createUnmergeableException(oldDb, oldStructure, changed, byRef, byId);
}
if (byRef == null && byId == null) {
parentBuilder.put(changed.immutableCopy());
return;
}
assert byRef != null;
assert byId != null;
ImmutableMetaDocPart.Builder childBuilder = new ImmutableMetaDocPart.Builder(byId);
for (ImmutableMetaField addedMetaField : changed.getAddedMetaFields()) {
merge(oldDb, newStructure, oldStructure, changed, byId, childBuilder, addedMetaField);
}
for (ImmutableMetaScalar addedMetaScalar : changed.getAddedMetaScalars()) {
merge(oldDb, oldStructure, byId, childBuilder, addedMetaScalar);
}
for (Tuple2<ImmutableMetaIdentifiedDocPartIndex, MetaElementState> addedMetaDocPartIndex : changed.getModifiedMetaDocPartIndexes()) {
merge(oldDb, newStructure, oldStructure, changed, byId, childBuilder, addedMetaDocPartIndex.v1(), addedMetaDocPartIndex.v2());
}
parentBuilder.put(childBuilder);
}
Aggregations