|
5 | 5 | import java.io.Writer;
|
6 | 6 |
|
7 | 7 | import org.apache.avro.io.BinaryDecoder;
|
| 8 | +import org.apache.avro.io.DecoderFactory; |
8 | 9 |
|
9 | 10 | import com.fasterxml.jackson.core.*;
|
10 | 11 | import com.fasterxml.jackson.core.io.IOContext;
|
|
17 | 18 | */
|
18 | 19 | public class ApacheAvroParserImpl extends AvroParserImpl
|
19 | 20 | {
|
| 21 | + /** |
| 22 | + * @since 2.16 |
| 23 | + */ |
| 24 | + protected final static DecoderFactory DECODER_FACTORY = DecoderFactory.get(); |
| 25 | + |
20 | 26 | /*
|
21 | 27 | /**********************************************************
|
22 | 28 | /* Input source config
|
@@ -74,17 +80,21 @@ public ApacheAvroParserImpl(IOContext ctxt, int parserFeatures, int avroFeatures
|
74 | 80 | _inputEnd = 0;
|
75 | 81 | _bufferRecyclable = true;
|
76 | 82 |
|
77 |
| - _decoder = ApacheCodecRecycler.decoder(in, |
78 |
| - Feature.AVRO_BUFFERING.enabledIn(avroFeatures)); |
| 83 | + final boolean buffering = Feature.AVRO_BUFFERING.enabledIn(avroFeatures); |
| 84 | + BinaryDecoder decoderToReuse = ApacheCodecRecycler.acquireDecoder(); |
| 85 | + _decoder = buffering |
| 86 | + ? DECODER_FACTORY.binaryDecoder(in, decoderToReuse) |
| 87 | + : DECODER_FACTORY.directBinaryDecoder(in, decoderToReuse); |
79 | 88 | }
|
80 | 89 |
|
81 | 90 | public ApacheAvroParserImpl(IOContext ctxt, int parserFeatures, int avroFeatures,
|
82 | 91 | ObjectCodec codec,
|
83 |
| - byte[] data, int offset, int len) |
| 92 | + byte[] buffer, int offset, int len) |
84 | 93 | {
|
85 | 94 | super(ctxt, parserFeatures, avroFeatures, codec);
|
86 | 95 | _inputStream = null;
|
87 |
| - _decoder = ApacheCodecRecycler.decoder(data, offset, len); |
| 96 | + BinaryDecoder decoderToReuse = ApacheCodecRecycler.acquireDecoder(); |
| 97 | + _decoder = DECODER_FACTORY.binaryDecoder(buffer, offset, len, decoderToReuse); |
88 | 98 | }
|
89 | 99 |
|
90 | 100 | @Override
|
|
0 commit comments