use of com.torodb.core.transaction.metainf.MetaDatabase in project torodb by torodb.
the class SqlTorodTransaction method findByAttRef.
@Override
public TorodCursor findByAttRef(String dbName, String colName, AttributeReference attRef, KvValue<?> value) {
MetaDatabase db = getInternalTransaction().getMetaSnapshot().getMetaDatabaseByName(dbName);
if (db == null) {
LOGGER.trace("Db with name " + dbName + " does not exist. An empty cursor is returned");
return new EmptyTorodCursor();
}
MetaCollection col = db.getMetaCollectionByName(colName);
if (col == null) {
LOGGER.trace("Collection " + dbName + '.' + colName + " does not exist. An empty cursor is returned");
return new EmptyTorodCursor();
}
TableRef ref = extractTableRef(attRef);
String lastKey = extractKeyName(attRef.getKeys().get(attRef.getKeys().size() - 1));
MetaDocPart docPart = col.getMetaDocPartByTableRef(ref);
if (docPart == null) {
LOGGER.trace("DocPart " + dbName + '.' + colName + '.' + ref + " does not exist. An empty cursor is returned");
return new EmptyTorodCursor();
}
MetaField field = docPart.getMetaFieldByNameAndType(lastKey, FieldType.from(value.getType()));
if (field == null) {
LOGGER.trace("Field " + dbName + '.' + colName + '.' + ref + '.' + lastKey + " does not exist. An empty cursor is returned");
return new EmptyTorodCursor();
}
return toToroCursor(getInternalTransaction().getBackendTransaction().findByField(db, col, docPart, field, value));
}
use of com.torodb.core.transaction.metainf.MetaDatabase in project torodb by torodb.
the class SqlTorodTransaction method getDocumentsSize.
@Override
public long getDocumentsSize(String dbName, String colName) {
MetaDatabase db = getInternalTransaction().getMetaSnapshot().getMetaDatabaseByName(dbName);
if (db == null) {
return 0;
}
MetaCollection col = db.getMetaCollectionByName(colName);
if (col == null) {
return 0;
}
return getInternalTransaction().getBackendTransaction().getDocumentsSize(db, col);
}
use of com.torodb.core.transaction.metainf.MetaDatabase in project torodb by torodb.
the class SqlTorodTransaction method getIndexesInfo.
@Override
public Stream<IndexInfo> getIndexesInfo(String dbName, String colName) {
MetaDatabase db = getInternalTransaction().getMetaSnapshot().getMetaDatabaseByName(dbName);
if (db == null) {
return Stream.empty();
}
MetaCollection col = db.getMetaCollectionByName(colName);
if (col == null) {
return Stream.empty();
}
return col.streamContainedMetaIndexes().map(metaIdx -> createIndexInfo(metaIdx));
}
use of com.torodb.core.transaction.metainf.MetaDatabase in project torodb by torodb.
the class SqlTorodTransaction method getCollectionInfo.
@Override
public CollectionInfo getCollectionInfo(String dbName, String colName) throws CollectionNotFoundException {
MetaDatabase db = getInternalTransaction().getMetaSnapshot().getMetaDatabaseByName(dbName);
if (db == null) {
throw new CollectionNotFoundException(dbName, colName);
}
MetaCollection col = db.getMetaCollectionByName(colName);
if (col == null) {
throw new CollectionNotFoundException(dbName, colName);
}
return new CollectionInfo(db.getMetaCollectionByName(colName).getName(), Json.createObjectBuilder().build());
}
use of com.torodb.core.transaction.metainf.MetaDatabase in project torodb by torodb.
the class SqlTorodTransaction method getIndexInfo.
@Override
public IndexInfo getIndexInfo(String dbName, String colName, String idxName) throws IndexNotFoundException {
MetaDatabase db = getInternalTransaction().getMetaSnapshot().getMetaDatabaseByName(dbName);
if (db == null) {
throw new IndexNotFoundException(dbName, colName, idxName);
}
MetaCollection col = db.getMetaCollectionByName(colName);
if (col == null) {
throw new IndexNotFoundException(dbName, colName, idxName);
}
MetaIndex idx = col.getMetaIndexByName(idxName);
if (idx == null) {
throw new IndexNotFoundException(dbName, colName, idxName);
}
return createIndexInfo(idx);
}
Aggregations