co.cask.cdap.conversion.avro
Class Converter

java.lang.Object
  extended by co.cask.cdap.conversion.avro.Converter

public class Converter
extends Object

Converts stream events into avro records.


Constructor Summary
Converter(org.apache.avro.Schema avroSchema, String[] headerFields)
          Create a converter that can be used to convert stream events into avro records.
 
Method Summary
 org.apache.avro.generic.GenericRecord convert(Object streamBody, long timestamp, Map<String,String> headers)
          Convert a StructuredRecord of the stream event body, the stream event timestamp, and the headers for the stream event into a GenericRecord of the given schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter(org.apache.avro.Schema avroSchema,
                 String[] headerFields)
Create a converter that can be used to convert stream events into avro records.

Parameters:
avroSchema - the schema for generated avro records
headerFields - fields of the schema that should take their values from a stream event's headers
Method Detail

convert

public org.apache.avro.generic.GenericRecord convert(Object streamBody,
                                                     long timestamp,
                                                     Map<String,String> headers)
Convert a StructuredRecord of the stream event body, the stream event timestamp, and the headers for the stream event into a GenericRecord of the given schema.

Parameters:
streamBody - the body of the stream event
timestamp - the timestamp of the stream event
headers - headers of the stream event
Returns:
the stream event as an avro record
Throws:
UnexpectedFormatException - if there was an error during conversion due to incompatible fields


Copyright © 2015 Cask Data, Inc. Licensed under the Apache License, Version 2.0.