use of org.apache.avro.file.SeekableByteArrayInput in project nifi by apache.
the class TestMergeContent method getGenericRecordMap.
private Map<String, GenericRecord> getGenericRecordMap(byte[] data, Schema schema, String key) throws IOException {
// create a reader for the merged contet
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(schema);
SeekableByteArrayInput input = new SeekableByteArrayInput(data);
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(input, datumReader);
// read all the records into a map to verify all the records are there
Map<String, GenericRecord> records = new HashMap<>();
while (dataFileReader.hasNext()) {
GenericRecord user = dataFileReader.next();
records.put(user.get(key).toString(), user);
}
return records;
}
Aggregations