{
Decoder inputDecoder = (_inputFormat == AvroFormat.BINARY) ?
DecoderFactory.defaultFactory().createBinaryDecoder(in, null) :
(AvroFormat.JSON == _inputFormat) ?
new JsonDecoder(_inputSchema, in) :
null;
ArrayList<GenericRecord> result = new ArrayList<GenericRecord>();
GenericDatumReader<GenericRecord> genericReader = _inputSchema != _outputSchema ?
new GenericDatumReader<GenericRecord>(_inputSchema, _outputSchema) :
new GenericDatumReader<GenericRecord>(_inputSchema);
switch (_inputFormat)
{
case BINARY:
case JSON:
{
GenericRecord r = genericReader.read(null, inputDecoder);
result.add(r);
break;
}
case JSON_LINES:
{
InputStreamReader inReader = new InputStreamReader(in);
try
{
BufferedReader lineIn = new BufferedReader(inReader);
try
{
String line;
while (null != (line = lineIn.readLine()))
{
inputDecoder = new JsonDecoder(_inputSchema, line);
GenericRecord r = genericReader.read(null, inputDecoder);
result.add(r);
break;
}
}