Search in sources :

Example 41 with Type

use of org.apache.avro.Schema.Type in project apex-malhar by apache.

the class AvroRecordHelper method convertValueStringToAvroKeyType.

/**
 * Convert a passed String value to the given type for the key as per Schema
 */
public static Object convertValueStringToAvroKeyType(Schema schema, String key, String value) throws ParseException {
    Type type = null;
    if (schema.getField(key) != null) {
        type = schema.getField(key).schema().getType();
    } else {
        return value;
    }
    Object convertedValue = null;
    if (type == Type.UNION) {
        convertedValue = convertAndResolveUnionToPrimitive(schema, key, value);
    } else {
        convertedValue = convertValueToAvroPrimitive(type, key, value);
    }
    return convertedValue;
}
Also used : Type(org.apache.avro.Schema.Type)

Aggregations

Type (org.apache.avro.Schema.Type)41 Schema (org.apache.avro.Schema)28 Field (org.apache.avro.Schema.Field)13 DataType (com.linkedin.pinot.common.data.FieldSpec.DataType)6 ByteBuffer (java.nio.ByteBuffer)6 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 SQLException (java.sql.SQLException)4 PersistentBase (org.apache.gora.persistency.impl.PersistentBase)4 EventCreationException (com.linkedin.databus2.producers.EventCreationException)3 SourceType (com.linkedin.databus2.relay.config.ReplicationBitSetterStaticConfig.SourceType)3 IOException (java.io.IOException)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 GenericArray (org.apache.avro.generic.GenericArray)3 Utf8 (org.apache.avro.util.Utf8)3 DocumentFieldType (org.apache.gora.mongodb.store.MongoMapping.DocumentFieldType)3 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)2