Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2052

Remove org.apache.avro.file.DataFileWriter Double Buffering

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Not A Problem
    • 1.7.7, 1.8.2
    • None
    • java
    • None
    • Patch

    Description

      org.apache.avro.file.DataFileWriter
        private void init(OutputStream outs) throws IOException {
          this.underlyingStream = outs;
          this.out = new BufferedFileOutputStream(outs);
          EncoderFactory efactory = new EncoderFactory();
          this.vout = efactory.binaryEncoder(out, null);
          dout.setSchema(schema);
          buffer = new NonCopyingByteArrayOutputStream(
              Math.min((int)(syncInterval * 1.25), Integer.MAX_VALUE/2 -1));
          this.bufOut = efactory.binaryEncoder(buffer, null);
          if (this.codec == null) {
            this.codec = CodecFactory.nullCodec().createInstance();
          }
          this.isOpen = true;
        }
      

      It's clear here that both streams are writing to a buffered destination, {{ BufferedFileOutputStream}} and ByteArrayOutputStream therefore there is no reason to need a buffered encoder and instead, write directly to the buffered streams with directBinaryEncoder.

      Attachments

        1. AVRO-2052.1.patch
          1 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: