Search in sources :

Example 11 with DocumentFieldType

use of org.apache.gora.mongodb.store.MongoMapping.DocumentFieldType in project gora by apache.

the class MongoStore method recordToMongo.

private BasicDBObject recordToMongo(final String docf, final Schema fieldSchema, final Object value) {
    BasicDBObject record = new BasicDBObject();
    for (Field member : fieldSchema.getFields()) {
        Object innerValue = ((PersistentBase) value).get(member.pos());
        String innerDoc = mapping.getDocumentField(member.name());
        Type innerType = member.schema().getType();
        DocumentFieldType innerStoreType = mapping.getDocumentFieldType(innerDoc);
        LOG.debug("Transform value to DBObject (RECORD), docField:{}, schemaType:{}, storeType:{}", new Object[] { member.name(), member.schema().getType(), innerStoreType });
        record.put(member.name(), toDBObject(docf, member.schema(), innerType, innerStoreType, innerValue));
    }
    return record;
}
Also used : Field(org.apache.avro.Schema.Field) PersistentBase(org.apache.gora.persistency.impl.PersistentBase) DocumentFieldType(org.apache.gora.mongodb.store.MongoMapping.DocumentFieldType) Type(org.apache.avro.Schema.Type) DocumentFieldType(org.apache.gora.mongodb.store.MongoMapping.DocumentFieldType)

Aggregations

DocumentFieldType (org.apache.gora.mongodb.store.MongoMapping.DocumentFieldType)11 Field (org.apache.avro.Schema.Field)5 Schema (org.apache.avro.Schema)4 BSONDecorator (org.apache.gora.mongodb.utils.BSONDecorator)4 Type (org.apache.avro.Schema.Type)3 PersistentBase (org.apache.gora.persistency.impl.PersistentBase)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Utf8 (org.apache.avro.util.Utf8)1 BeanFactoryImpl (org.apache.gora.persistency.impl.BeanFactoryImpl)1 DirtyListWrapper (org.apache.gora.persistency.impl.DirtyListWrapper)1 DirtyMapWrapper (org.apache.gora.persistency.impl.DirtyMapWrapper)1