Search in sources :

Example 6 with MutableMetaCollection

use of com.torodb.core.transaction.metainf.MutableMetaCollection in project torodb by torodb.

the class D2RTranslationBatchFunctionTest method setUp.

@Before
public void setUp() {
    metaDb = new WrapperMutableMetaDatabase(new ImmutableMetaDatabase("dbName", "dbId", Collections.emptyList()), (o) -> {
    });
    metaCol = metaDb.addMetaCollection("colName", "colId");
    translatorFactory = mock(D2RTranslatorFactory.class);
    fun = new D2RTranslationBatchFunction(translatorFactory, metaDb, metaCol) {

        @Override
        protected BatchMetaCollection createMetaDocCollection(MutableMetaCollection metaCol) {
            batchMetaCol = spy(super.createMetaDocCollection(metaCol));
            return batchMetaCol;
        }
    };
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) WrapperMutableMetaCollection(com.torodb.core.transaction.metainf.WrapperMutableMetaCollection) Test(org.junit.Test) D2RTranslatorFactory(com.torodb.core.d2r.D2RTranslatorFactory) Mockito(org.mockito.Mockito) MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) List(java.util.List) Lists(com.google.common.collect.Lists) BDDMockito.given(org.mockito.BDDMockito.given) WrapperMutableMetaDatabase(com.torodb.core.transaction.metainf.WrapperMutableMetaDatabase) CollectionData(com.torodb.core.d2r.CollectionData) D2RTranslator(com.torodb.core.d2r.D2RTranslator) ImmutableMetaDatabase(com.torodb.core.transaction.metainf.ImmutableMetaDatabase) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) WrapperMutableMetaDatabase(com.torodb.core.transaction.metainf.WrapperMutableMetaDatabase) WrapperMutableMetaCollection(com.torodb.core.transaction.metainf.WrapperMutableMetaCollection) MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) ImmutableMetaDatabase(com.torodb.core.transaction.metainf.ImmutableMetaDatabase) D2RTranslatorFactory(com.torodb.core.d2r.D2RTranslatorFactory) Before(org.junit.Before)

Example 7 with MutableMetaCollection

use of com.torodb.core.transaction.metainf.MutableMetaCollection in project torodb by torodb.

the class SqlExclusiveWriteTorodTransaction method renameCollection.

@Override
public void renameCollection(String fromDb, String fromCollection, String toDb, String toCollection) throws RollbackException, UserException {
    MutableMetaDatabase fromMetaDb = getMetaDatabaseOrThrowException(fromDb);
    MetaCollection fromMetaColl = getMetaCollectionOrThrowException(fromMetaDb, fromCollection);
    MutableMetaDatabase toMetaDb = getOrCreateMetaDatabase(toDb);
    MutableMetaCollection toMetaColl = createMetaCollection(toMetaDb, toCollection);
    getInternalTransaction().getBackendTransaction().renameCollection(fromMetaDb, fromMetaColl, toMetaDb, toMetaColl);
    fromMetaDb.removeMetaCollectionByName(fromCollection);
}
Also used : MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) MetaCollection(com.torodb.core.transaction.metainf.MetaCollection) MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase)

Example 8 with MutableMetaCollection

use of com.torodb.core.transaction.metainf.MutableMetaCollection in project torodb by torodb.

the class SqlWriteTorodTransaction method insert.

@Override
public void insert(String db, String collection, Stream<KvDocument> documents) throws RollbackException, UserException {
    Preconditions.checkState(!isClosed());
    MutableMetaDatabase metaDb = getOrCreateMetaDatabase(db);
    MutableMetaCollection metaCol = getOrCreateMetaCollection(metaDb, collection);
    //TODO: here we can not use a pipeline
    InsertPipeline pipeline = getConnection().getServer().getInsertPipelineFactory().createInsertPipeline(getConnection().getServer().getD2RTranslatorFactory(), metaDb, metaCol, getInternalTransaction().getBackendTransaction(), concurrent);
    pipeline.insert(documents);
}
Also used : MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase) InsertPipeline(com.torodb.torod.pipeline.InsertPipeline)

Aggregations

MutableMetaCollection (com.torodb.core.transaction.metainf.MutableMetaCollection)8 MutableMetaDatabase (com.torodb.core.transaction.metainf.MutableMetaDatabase)5 CollectionData (com.torodb.core.d2r.CollectionData)2 D2RTranslatorFactory (com.torodb.core.d2r.D2RTranslatorFactory)2 MutableMetaIndex (com.torodb.core.transaction.metainf.MutableMetaIndex)2 KvDocument (com.torodb.kvdocument.values.KvDocument)2 InsertPipeline (com.torodb.torod.pipeline.InsertPipeline)2 Preconditions (com.google.common.base.Preconditions)1 Iterators (com.google.common.collect.Iterators)1 Lists (com.google.common.collect.Lists)1 Assisted (com.google.inject.assistedinject.Assisted)1 TableRef (com.torodb.core.TableRef)1 WriteBackendTransaction (com.torodb.core.backend.WriteBackendTransaction)1 D2RTranslator (com.torodb.core.d2r.D2RTranslator)1 BackendTransactionJob (com.torodb.core.dsl.backend.BackendTransactionJob)1 BackendTransactionJobFactory (com.torodb.core.dsl.backend.BackendTransactionJobFactory)1 UnsupportedCompoundIndexException (com.torodb.core.exceptions.user.UnsupportedCompoundIndexException)1 UnsupportedUniqueIndexException (com.torodb.core.exceptions.user.UnsupportedUniqueIndexException)1 UserException (com.torodb.core.exceptions.user.UserException)1 AttributeReference (com.torodb.core.language.AttributeReference)1