Search in sources :

Example 1 with MutableMetaDatabase

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

the class SqlWriteTorodTransaction method createCollection.

@Override
public void createCollection(String db, String collection) throws RollbackException, UserException {
    MutableMetaDatabase metaDb = getOrCreateMetaDatabase(db);
    getOrCreateMetaCollection(metaDb, collection);
}
Also used : MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase)

Example 2 with MutableMetaDatabase

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

the class SqlWriteTorodTransaction method getOrCreateMetaDatabase.

@Nonnull
protected MutableMetaDatabase getOrCreateMetaDatabase(String dbName) {
    MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
    MutableMetaDatabase metaDb = metaSnapshot.getMetaDatabaseByName(dbName);
    if (metaDb == null) {
        metaDb = createMetaDatabase(dbName);
    }
    return metaDb;
}
Also used : MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase) Nonnull(javax.annotation.Nonnull)

Example 3 with MutableMetaDatabase

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

the class SqlWriteTorodTransaction method getMetaDatabaseOrThrowException.

@Nonnull
protected MutableMetaDatabase getMetaDatabaseOrThrowException(@Nonnull String dbName) throws DatabaseNotFoundException {
    MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
    MutableMetaDatabase metaDb = metaSnapshot.getMetaDatabaseByName(dbName);
    if (metaDb == null) {
        throw new DatabaseNotFoundException(dbName);
    }
    return metaDb;
}
Also used : MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) DatabaseNotFoundException(com.torodb.core.exceptions.user.DatabaseNotFoundException) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase) Nonnull(javax.annotation.Nonnull)

Example 4 with MutableMetaDatabase

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

the class SqlWriteTorodTransaction method dropCollection.

@Override
public void dropCollection(String db, String collection) throws RollbackException, UserException {
    MutableMetaDatabase metaDb = getMetaDatabaseOrThrowException(db);
    MutableMetaCollection metaColl = getMetaCollectionOrThrowException(metaDb, collection);
    getInternalTransaction().getBackendTransaction().dropCollection(metaDb, metaColl);
    metaDb.removeMetaCollectionByName(collection);
}
Also used : MutableMetaCollection(com.torodb.core.transaction.metainf.MutableMetaCollection) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase)

Example 5 with MutableMetaDatabase

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

the class SqlWriteTorodTransaction method createMetaDatabase.

private MutableMetaDatabase createMetaDatabase(String dbName) {
    Preconditions.checkState(!isClosed());
    MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
    MutableMetaDatabase metaDb = metaSnapshot.addMetaDatabase(dbName, getConnection().getServer().getIdentifierFactory().toDatabaseIdentifier(metaSnapshot, dbName));
    getInternalTransaction().getBackendTransaction().addDatabase(metaDb);
    return metaDb;
}
Also used : MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) MutableMetaDatabase(com.torodb.core.transaction.metainf.MutableMetaDatabase)

Aggregations

MutableMetaDatabase (com.torodb.core.transaction.metainf.MutableMetaDatabase)10 MutableMetaCollection (com.torodb.core.transaction.metainf.MutableMetaCollection)5 MutableMetaSnapshot (com.torodb.core.transaction.metainf.MutableMetaSnapshot)3 MutableMetaIndex (com.torodb.core.transaction.metainf.MutableMetaIndex)2 Nonnull (javax.annotation.Nonnull)2 TableRef (com.torodb.core.TableRef)1 DatabaseNotFoundException (com.torodb.core.exceptions.user.DatabaseNotFoundException)1 UnsupportedCompoundIndexException (com.torodb.core.exceptions.user.UnsupportedCompoundIndexException)1 UnsupportedUniqueIndexException (com.torodb.core.exceptions.user.UnsupportedUniqueIndexException)1 AttributeReference (com.torodb.core.language.AttributeReference)1 FieldIndexOrdering (com.torodb.core.transaction.metainf.FieldIndexOrdering)1 MetaCollection (com.torodb.core.transaction.metainf.MetaCollection)1 MetaIndex (com.torodb.core.transaction.metainf.MetaIndex)1 IndexFieldInfo (com.torodb.torod.IndexFieldInfo)1 InsertPipeline (com.torodb.torod.pipeline.InsertPipeline)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 Tuple3 (org.jooq.lambda.tuple.Tuple3)1