Search in sources :

Example 21 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class D2RTranslationBatchFunction method apply.

@Override
public CollectionData apply(List<KvDocument> docs) {
    metaDocCollection.newBatch();
    D2RTranslator translator = translatorFactory.createTranslator(metaDatabase, metaDocCollection);
    for (KvDocument doc : docs) {
        translator.translate(doc);
    }
    return translator.getCollectionDataAccumulator();
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) D2RTranslator(com.torodb.core.d2r.D2RTranslator)

Example 22 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseMultiArrayEmpty.

@Test
public void parseMultiArrayEmpty() {
    KvDocument doc = parser.createFromResource("MultiArrayEmpty.json");
    KvArray array = (KvArray) doc.get("months");
    assertEquals(1, array.size());
    assertTrue(array.get(0) instanceof KvArray);
    KvArray inner = (KvArray) array.get(0);
    assertEquals(0, inner.size());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvArray(com.torodb.kvdocument.values.KvArray) Test(org.junit.Test)

Example 23 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseEmptyArray.

@Test
public void parseEmptyArray() {
    KvDocument doc = parser.createFromResource("EmptyArray.json");
    assertTrue(doc.containsKey("department"));
    assertTrue(doc.get("department") instanceof KvArray);
    assertTrue(((KvArray) doc.get("department")).size() == 0);
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) KvArray(com.torodb.kvdocument.values.KvArray) Test(org.junit.Test)

Example 24 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseEmptyJson.

@Test
public void parseEmptyJson() {
    KvDocument doc = parser.createFromResource("Empty.json");
    assertEquals(0, doc.size());
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) Test(org.junit.Test)

Example 25 with KvDocument

use of com.torodb.kvdocument.values.KvDocument in project torodb by torodb.

the class TestConvertJson method parseSubDocument.

@Test
public void parseSubDocument() {
    KvDocument doc = parser.createFromResource("SubDocument.json");
    assertTrue(doc.containsKey("address"));
    assertTrue(doc.get("address") instanceof KvDocument);
}
Also used : KvDocument(com.torodb.kvdocument.values.KvDocument) Test(org.junit.Test)

Aggregations

KvDocument (com.torodb.kvdocument.values.KvDocument)30 Test (org.junit.Test)23 ToroDocument (com.torodb.core.document.ToroDocument)10 DocPartResult (com.torodb.core.d2r.DocPartResult)9 R2DTranslator (com.torodb.core.d2r.R2DTranslator)9 KvArray (com.torodb.kvdocument.values.KvArray)8 TableRef (com.torodb.core.TableRef)4 UserException (com.torodb.core.exceptions.user.UserException)3 Status (com.eightkdata.mongowp.Status)2 BsonDocument (com.eightkdata.mongowp.bson.BsonDocument)2 CollectionData (com.torodb.core.d2r.CollectionData)2 D2RTranslator (com.torodb.core.d2r.D2RTranslator)2 AttributeReference (com.torodb.core.language.AttributeReference)2 ObjectKey (com.torodb.core.language.AttributeReference.ObjectKey)2 MongoWpConverter (com.torodb.kvdocument.conversion.mongowp.MongoWpConverter)2 KvValue (com.torodb.kvdocument.values.KvValue)2 MapKvDocument (com.torodb.kvdocument.values.heap.MapKvDocument)2 UpdatedToroDocumentBuilder (com.torodb.mongodb.language.update.UpdatedToroDocumentBuilder)2 IndexFieldInfo (com.torodb.torod.IndexFieldInfo)2 ErrorCode (com.eightkdata.mongowp.ErrorCode)1