Search in sources :

Example 16 with TableRef

use of com.torodb.core.TableRef in project torodb by torodb.

the class AbstractMetaDataReadInterface method getForeignInternalFields.

@Override
public Collection<InternalField<?>> getForeignInternalFields(TableRef tableRef) {
    Preconditions.checkArgument(!tableRef.isRoot());
    TableRef parentTableRef = tableRef.getParent().get();
    if (parentTableRef.isRoot()) {
        return metaDocPartTable.FOREIGN_ROOT_FIELDS;
    } else if (parentTableRef.getParent().get().isRoot()) {
        return metaDocPartTable.FOREIGN_FIRST_FIELDS;
    }
    return metaDocPartTable.FOREIGN_FIELDS;
}
Also used : TableRef(com.torodb.core.TableRef)

Example 17 with TableRef

use of com.torodb.core.TableRef in project torodb by torodb.

the class TableRefConverter method fromJsonArray.

public static TableRef fromJsonArray(TableRefFactory tableRefFactory, JsonArray tableRefJsonArray) {
    TableRef tableRef = tableRefFactory.createRoot();
    for (JsonValue tableRefNameValue : tableRefJsonArray) {
        String tableRefName = ((JsonString) tableRefNameValue).getString();
        tableRef = createChild(tableRefFactory, tableRef, tableRefName);
    }
    return tableRef;
}
Also used : JsonValue(javax.json.JsonValue) JsonString(javax.json.JsonString) JsonString(javax.json.JsonString) TableRef(com.torodb.core.TableRef)

Example 18 with TableRef

use of com.torodb.core.TableRef in project torodb by torodb.

the class ReservedIdInfoFactoryImpl method loadRowIds.

@SuppressWarnings("checkstyle:LineLength")
private ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<TableRef, ReservedIdInfo>>> loadRowIds(DSLContext dsl, MetaSnapshot snapshot) {
    ConcurrentHashMap<String, ConcurrentHashMap<String, ConcurrentHashMap<TableRef, ReservedIdInfo>>> rowsIdMap = new ConcurrentHashMap<>();
    snapshot.streamMetaDatabases().forEach(db -> {
        ConcurrentHashMap<String, ConcurrentHashMap<TableRef, ReservedIdInfo>> collMap = new ConcurrentHashMap<>();
        rowsIdMap.put(db.getName(), collMap);
        db.streamMetaCollections().forEach(collection -> {
            ConcurrentHashMap<TableRef, ReservedIdInfo> tableRefMap = new ConcurrentHashMap<>();
            collMap.put(collection.getName(), tableRefMap);
            collection.streamContainedMetaDocParts().forEach(metaDocPart -> {
                TableRef tableRef = metaDocPart.getTableRef();
                Integer lastRowIUsed = sqlInterface.getReadInterface().getLastRowIdUsed(dsl, db, collection, metaDocPart);
                tableRefMap.put(tableRef, new ReservedIdInfo(lastRowIUsed, lastRowIUsed));
            });
        });
    });
    return rowsIdMap;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TableRef(com.torodb.core.TableRef)

Example 19 with TableRef

use of com.torodb.core.TableRef in project torodb by torodb.

the class TableRefImplTest method rootArrayInArrayTest.

@Test
public void rootArrayInArrayTest() throws Exception {
    TableRef tableRef = createTableRef("array", "2");
    Assert.assertEquals("$2", tableRef.getName());
    Assert.assertEquals(2, tableRef.getDepth());
    Assert.assertEquals(2, tableRef.getArrayDimension());
    Assert.assertEquals(false, tableRef.isRoot());
    Assert.assertEquals(true, tableRef.isInArray());
    Assert.assertEquals(true, tableRef.getParent().isPresent());
}
Also used : TableRef(com.torodb.core.TableRef) Test(org.junit.Test)

Example 20 with TableRef

use of com.torodb.core.TableRef in project torodb by torodb.

the class TableRefImplTest method rootObjectTest.

@Test
public void rootObjectTest() throws Exception {
    TableRef tableRef = createTableRef("object");
    Assert.assertEquals("object", tableRef.getName());
    Assert.assertEquals(1, tableRef.getDepth());
    Assert.assertEquals(0, tableRef.getArrayDimension());
    Assert.assertEquals(false, tableRef.isRoot());
    Assert.assertEquals(false, tableRef.isInArray());
    Assert.assertEquals(true, tableRef.getParent().isPresent());
}
Also used : TableRef(com.torodb.core.TableRef) Test(org.junit.Test)

Aggregations

TableRef (com.torodb.core.TableRef)32 Test (org.junit.Test)13 MetaDocPart (com.torodb.core.transaction.metainf.MetaDocPart)6 DocPartResult (com.torodb.core.d2r.DocPartResult)5 ToroDocument (com.torodb.core.document.ToroDocument)5 MetaCollection (com.torodb.core.transaction.metainf.MetaCollection)5 MetaDatabase (com.torodb.core.transaction.metainf.MetaDatabase)5 R2DTranslator (com.torodb.core.d2r.R2DTranslator)4 MetaField (com.torodb.core.transaction.metainf.MetaField)4 KvDocument (com.torodb.kvdocument.values.KvDocument)4 KvArray (com.torodb.kvdocument.values.KvArray)3 KvValue (com.torodb.kvdocument.values.KvValue)3 MetaIdentifiedDocPartIndex (com.torodb.core.transaction.metainf.MetaIdentifiedDocPartIndex)2 MutableMetaCollection (com.torodb.core.transaction.metainf.MutableMetaCollection)2 MutableMetaDatabase (com.torodb.core.transaction.metainf.MutableMetaDatabase)2 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)2 EmptyTorodCursor (com.torodb.torod.cursors.EmptyTorodCursor)2 ArrayList (java.util.ArrayList)2 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1