[
https://issues.apache.org/jira/browse/AVRO-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17070940#comment-17070940
]
Zezeng Wang commented on AVRO-2786:
-----------------------------------
But when adding a string to the buff in Object [] loop, initializing the buffer
size of the buff is still a very troublesome problem, which has been bothering
me recently. It seems that there is no good solution. Any suggestions are
welcome.
> Initialize the buffer area for StringBuilder/List
> -------------------------------------------------
>
> Key: AVRO-2786
> URL: https://issues.apache.org/jira/browse/AVRO-2786
> Project: Apache Avro
> Issue Type: Wish
> Components: java
> Reporter: Zezeng Wang
> Priority: Minor
>
> 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]
> {code:java}
> final List<?> list = (List<?>) value;
> final List<String> annots = new ArrayList<>(); //-----init
> for(Object o : list){
> annots.add(o.toString());
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)