Search in sources :

Example 16 with SingleRecordIterable

use of org.apache.gobblin.converter.SingleRecordIterable in project incubator-gobblin by apache.

the class AvroToCouchbaseTupleConverter method convertRecord.

@Override
public Iterable<TupleDocument> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException {
    String key = inputRecord.get(keyField).toString();
    GenericRecord data = (GenericRecord) inputRecord.get(dataRecordField);
    ByteBuffer dataBytes = (ByteBuffer) data.get(valueField);
    Integer flags = (Integer) data.get(flagsField);
    ByteBuf buffer = Unpooled.copiedBuffer(dataBytes);
    return new SingleRecordIterable<>(new TupleDocument(key, Tuple.create(buffer, flags)));
}
Also used : SingleRecordIterable(org.apache.gobblin.converter.SingleRecordIterable) GenericRecord(org.apache.avro.generic.GenericRecord) ByteBuf(com.couchbase.client.deps.io.netty.buffer.ByteBuf) TupleDocument(org.apache.gobblin.couchbase.common.TupleDocument) ByteBuffer(java.nio.ByteBuffer)

Aggregations

SingleRecordIterable (org.apache.gobblin.converter.SingleRecordIterable)16 JsonObject (com.google.gson.JsonObject)7 GenericRecord (org.apache.avro.generic.GenericRecord)7 DataConversionException (org.apache.gobblin.converter.DataConversionException)7 Map (java.util.Map)6 JsonElement (com.google.gson.JsonElement)5 JsonParser (com.google.gson.JsonParser)2 IOException (java.io.IOException)2 Schema (org.apache.avro.Schema)2 Field (org.apache.avro.Schema.Field)2 SchemaConversionException (org.apache.gobblin.converter.SchemaConversionException)2 ByteBuf (com.couchbase.client.deps.io.netty.buffer.ByteBuf)1 RawJsonDocument (com.couchbase.client.java.document.RawJsonDocument)1 Optional (com.google.common.base.Optional)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Config (com.typesafe.config.Config)1 ByteBuffer (java.nio.ByteBuffer)1 Date (java.sql.Date)1 Time (java.sql.Time)1 Timestamp (java.sql.Timestamp)1