Search in sources :

Example 21 with TableRef

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());
}
Also used : TableRef(com.torodb.core.TableRef) Test(org.junit.Test)

Example 22 with TableRef

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);
                }
            }
        }
    }
}
Also used : MutableMetaDocPart(com.torodb.core.transaction.metainf.MutableMetaDocPart) ArrayList(java.util.ArrayList) List(java.util.List) TableRef(com.torodb.core.TableRef)

Example 23 with TableRef

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);
    }
}
Also used : TableRef(com.torodb.core.TableRef) Test(org.junit.Test)

Example 24 with 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;
}
Also used : TableRef(com.torodb.core.TableRef)

Example 25 with TableRef

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