Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/3160#discussion_r232119197
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java
 ---
    @@ -33,24 +28,34 @@
     import org.apache.nifi.serialization.record.Record;
     import org.apache.nifi.serialization.record.RecordSchema;
     
    +import java.io.BufferedOutputStream;
    +import java.io.IOException;
    +import java.io.OutputStream;
    +import java.util.Map;
    +import java.util.concurrent.BlockingQueue;
    +
     public class WriteAvroResultWithExternalSchema extends 
AbstractRecordSetWriter {
         private final SchemaAccessWriter schemaAccessWriter;
         private final RecordSchema recordSchema;
         private final Schema avroSchema;
         private final BinaryEncoder encoder;
         private final OutputStream buffered;
         private final DatumWriter<GenericRecord> datumWriter;
    +    private final BlockingQueue<BinaryEncoder> recycleQueue;
     
         public WriteAvroResultWithExternalSchema(final Schema avroSchema, 
final RecordSchema recordSchema,
    -        final SchemaAccessWriter schemaAccessWriter, final OutputStream 
out) throws IOException {
    +        final SchemaAccessWriter schemaAccessWriter, final OutputStream 
out, final BlockingQueue<BinaryEncoder> recycleQueue) {
             super(out);
             this.recordSchema = recordSchema;
             this.schemaAccessWriter = schemaAccessWriter;
             this.avroSchema = avroSchema;
             this.buffered = new BufferedOutputStream(out);
    +        this.recycleQueue = recycleQueue;
    +
    +        BinaryEncoder reusableEncoder = recycleQueue.poll();
    +        encoder = EncoderFactory.get().blockingBinaryEncoder(buffered, 
reusableEncoder);
    --- End diff --
    
    Probably, we should add a debug log here to provide information whether 
current number of pool size fits the actual usage. If there are more null 
reusableEncorder and user want to improve performance, then they can increase 
pool size ... etc.


---

Reply via email to