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

DirectBinaryEncoder Creates Buffer For Each Call To writeDouble

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.7.7, 1.8.2
    • 1.9.0
    • java
    • None

    Description

      Each call to writeDouble creates a new buffer and promptly throws it away even though the class has a re-usable buffer and is used in other methods such as writeFloat. Remove this extra buffer.

      org.apache.avro.io.DirectBinaryEncoder
        // the buffer is used for writing floats, doubles, and large longs.
        private final byte[] buf = new byte[12];
      
        @Override
        public void writeFloat(float f) throws IOException {
          int len = BinaryData.encodeFloat(f, buf, 0);
          out.write(buf, 0, len);
        }
      
        @Override
        public void writeDouble(double d) throws IOException {
          byte[] buf = new byte[8];
          int len = BinaryData.encodeDouble(d, buf, 0);
          out.write(buf, 0, len);
        }
      

      Attachments

        1. AVRO-2056.1.patch
          0.7 kB
          David Mollitor

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: