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

Initialize the buffer area for StringBuilder/List

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.10.0
    • Component/s: java
    • Labels:
      None

      Description

      Under the StringBuilder/List is a char array to store. If the internal buffer overflows (the default length is 16/10), it will automatically become larger. A new internal buffer will be allocated to the array copy. Although it cannot be completely avoided, it can reduce the expansion It's not bad.
      E.g:
      https://github.com/apache/avro/blob/87aefa28ad6cb11ab95010cdeac2223cfb701c0d/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L964
      https://github.com/apache/avro/blob/87aefa28ad6cb11ab95010cdeac2223cfb701c0d/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L944

       final List<?> list = (List<?>) value;
       final List<String> annots = new ArrayList<>(); //-----init
       for(Object o : list){
          annots.add(o.toString()); 
       }
       

        Attachments

          Activity

            People

            • Assignee:
              zeshuai007 Zezeng Wang
              Reporter:
              zeshuai007 Zezeng Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: