Laurent Goujon created ARROW-13847:
--------------------------------------
Summary: Avoid unnecessary copies of collection
Key: ARROW-13847
URL: https://issues.apache.org/jira/browse/ARROW-13847
Project: Apache Arrow
Issue Type: Improvement
Components: Java
Reporter: Laurent Goujon
Assignee: Laurent Goujon
There are several occurences of unnecessary copies of collections in Arrow Java
code.
One typical example is for a constructor to copy a collection provided as an
argument, and then invoking {{Collections2}} method to create a immutable copy
of it, like for {{Schema}}
([https://github.com/apache/arrow/blob/247a7a9bf1b7090b1bffc14bec84d188dccb52dc/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java#L113)]
{code:java}
/**
* Constructor with metadata.
*/
public Schema(Iterable<Field> fields,
Map<String, String> metadata) {
List<Field> fieldList = new ArrayList<>();
for (Field field : fields) {
fieldList.add(field);
}
this.fields = Collections2.immutableListCopy(fieldList);
this.metadata = metadata == null ? Collections.emptyMap() :
Collections2.immutableMapCopy(metadata);
} {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)