}
private <T> Function<ByteBuffer, T> createInputDatumDecoder(final TypeToken<T> dataType, final Schema schema,
final SchemaCache schemaCache) {
final ReflectionDatumReader<T> datumReader = new ReflectionDatumReader<T>(schema, dataType);
final ByteBufferInputStream byteBufferInput = new ByteBufferInputStream(null);
final BinaryDecoder decoder = new BinaryDecoder(byteBufferInput);
return new Function<ByteBuffer, T>() {
@Nullable
@Override
public T apply(ByteBuffer input) {
byteBufferInput.reset(input);
try {
final Schema sourceSchema = schemaCache.get(input);
Preconditions.checkNotNull(sourceSchema, "Fail to find source schema.");
return datumReader.read(decoder, sourceSchema);
} catch (IOException e) {