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;
}
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;
}
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;
}
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());
}
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());
}
Aggregations