Search in sources :

Example 1 with IdentifierFactory

use of com.torodb.core.d2r.IdentifierFactory in project torodb by torodb.

the class ExclusiveWriteBackendTransactionImpl method copyMetaCollection.

private void copyMetaCollection(MetaDatabase fromDb, MetaCollection fromColl, MutableMetaDatabase toDb, MutableMetaCollection toColl) {
    IdentifierFactory identifierFactory = getIdentifierFactory();
    Iterator<? extends MetaIndex> fromMetaIndexIterator = fromColl.streamContainedMetaIndexes().iterator();
    while (fromMetaIndexIterator.hasNext()) {
        MetaIndex fromMetaIndex = fromMetaIndexIterator.next();
        MutableMetaIndex toMetaIndex = toColl.addMetaIndex(fromMetaIndex.getName(), fromMetaIndex.isUnique());
        getSqlInterface().getMetaDataWriteInterface().addMetaIndex(getDsl(), toDb, toColl, toMetaIndex);
        copyIndexFields(fromMetaIndex, toDb, toColl, toMetaIndex);
    }
    Iterator<? extends MetaDocPart> fromMetaDocPartIterator = fromColl.streamContainedMetaDocParts().iterator();
    while (fromMetaDocPartIterator.hasNext()) {
        MetaDocPart fromMetaDocPart = fromMetaDocPartIterator.next();
        MutableMetaDocPart toMetaDocPart = toColl.addMetaDocPart(fromMetaDocPart.getTableRef(), identifierFactory.toDocPartIdentifier(toDb, toColl.getName(), fromMetaDocPart.getTableRef()));
        getSqlInterface().getMetaDataWriteInterface().addMetaDocPart(getDsl(), toDb, toColl, toMetaDocPart);
        copyScalar(identifierFactory, fromMetaDocPart, toDb, toColl, toMetaDocPart);
        copyFields(identifierFactory, fromMetaDocPart, toDb, toColl, toMetaDocPart);
        copyIndexes(identifierFactory, fromMetaDocPart, toDb, toColl, toMetaDocPart);
        int nextRid = ridGenerator.getDocPartRidGenerator(fromDb.getName(), fromColl.getName()).nextRid(fromMetaDocPart.getTableRef());
        ridGenerator.getDocPartRidGenerator(toDb.getName(), toColl.getName()).setNextRid(toMetaDocPart.getTableRef(), nextRid - 1);
    }
}
Also used : MutableMetaIndex(com.torodb.core.transaction.metainf.MutableMetaIndex) MetaIndex(com.torodb.core.transaction.metainf.MetaIndex) MutableMetaDocPart(com.torodb.core.transaction.metainf.MutableMetaDocPart) MetaDocPart(com.torodb.core.transaction.metainf.MetaDocPart) MutableMetaDocPart(com.torodb.core.transaction.metainf.MutableMetaDocPart) MutableMetaIndex(com.torodb.core.transaction.metainf.MutableMetaIndex) IdentifierFactory(com.torodb.core.d2r.IdentifierFactory)

Aggregations

IdentifierFactory (com.torodb.core.d2r.IdentifierFactory)1 MetaDocPart (com.torodb.core.transaction.metainf.MetaDocPart)1 MetaIndex (com.torodb.core.transaction.metainf.MetaIndex)1 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)1 MutableMetaIndex (com.torodb.core.transaction.metainf.MutableMetaIndex)1