use of com.torodb.core.TableRef in project torodb by torodb.
the class TableRefImplTest method rootObjectObjectTest.
@Test
public void rootObjectObjectTest() throws Exception {
TableRef tableRef = createTableRef("object", "object");
Assert.assertEquals("object", tableRef.getName());
Assert.assertEquals(2, tableRef.getDepth());
Assert.assertEquals(0, tableRef.getArrayDimension());
Assert.assertEquals(false, tableRef.isRoot());
Assert.assertEquals(false, tableRef.isInArray());
Assert.assertEquals(true, tableRef.getParent().isPresent());
}
use of com.torodb.core.TableRef in project torodb by torodb.
the class SharedWriteBackendTransactionImpl method createMissingDocPartIndexes.
private void createMissingDocPartIndexes(MetaDatabase db, MutableMetaCollection col, MetaIndex index) throws UserException {
Iterator<TableRef> tableRefIterator = index.streamTableRefs().iterator();
while (tableRefIterator.hasNext()) {
TableRef tableRef = tableRefIterator.next();
MutableMetaDocPart docPart = col.getMetaDocPartByTableRef(tableRef);
if (docPart != null && index.isCompatible(docPart)) {
Iterator<List<String>> docPartIndexesFieldsIterator = index.iteratorMetaDocPartIndexesIdentifiers(docPart);
while (docPartIndexesFieldsIterator.hasNext()) {
List<String> identifiers = docPartIndexesFieldsIterator.next();
boolean containsExactDocPartIndex = docPart.streamIndexes().anyMatch(docPartIndex -> index.isMatch(docPart, identifiers, docPartIndex));
if (!containsExactDocPartIndex) {
createIndex(db, col, index, docPart, identifiers);
}
}
}
}
}
use of com.torodb.core.TableRef in project torodb by torodb.
the class Document2RelStackTest method collectionDataIsSortedByParentRelationship.
@Test
public void collectionDataIsSortedByParentRelationship() {
CollectionData collectionData = parseDocument("DocPartLevelSorted1.json", "DocPartLevelSorted2.json");
Set<TableRef> parsed = new HashSet<>();
for (DocPartData docPartData : collectionData.orderedDocPartData()) {
TableRef tableRef = docPartData.getMetaDocPart().getTableRef();
if (!tableRef.isRoot()) {
TableRef parent = tableRef.getParent().get();
assertTrue(parsed.contains(parent));
}
parsed.add(tableRef);
}
}
use of com.torodb.core.TableRef in project torodb by torodb.
the class PostgreSqlReadInterface method getLastRowIdUsedStatement.
@Override
protected String getLastRowIdUsedStatement(MetaDatabase metaDatabase, MetaDocPart metaDocPart) {
TableRef tableRef = metaDocPart.getTableRef();
StringBuilder sb = new StringBuilder();
sb.append("SELECT max(\"").append(getPrimaryKeyColumnIdentifier(tableRef)).append("\") FROM \"").append(metaDatabase.getIdentifier()).append("\".\"").append(metaDocPart.getIdentifier()).append("\"");
String statement = sb.toString();
return statement;
}
use of com.torodb.core.TableRef in project torodb by torodb.
the class TableRefImplTest method rootArrayTest.
@Test
public void rootArrayTest() throws Exception {
TableRef tableRef = createTableRef("array");
Assert.assertEquals("array", 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