[
https://issues.apache.org/jira/browse/AVRO-1607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zoltan Farkas updated AVRO-1607:
--------------------------------
Description:
In SpecificData.getClass, line 164:
{code}
case UNION:
List<Schema> types = schema.getTypes(); // elide unions with null
if ((types.size() == 2) && types.contains(NULL_SCHEMA))
return getWrapper(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 : 0));
return Object.class;
{code}
can be written more efficiently as:
{code}
case UNION:
List<Schema> types = schema.getTypes(); // elide unions with null
if ((types.size() == 2)) {
if (NULL_SCHEMA.equals(types.get(0))) {
return getWrapper(types.get(1));
} else if (NULL_SCHEMA.equals(types.get(1))) {
return getWrapper(types.get(0));
}
}
return Object.class;
{code}
was:
In SpecificData.getClass, line 164:
case UNION:
List<Schema> types = schema.getTypes(); // elide unions with null
if ((types.size() == 2) && types.contains(NULL_SCHEMA))
return getWrapper(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 : 0));
return Object.class;
can be written more efficiently as:
case UNION:
List<Schema> types = schema.getTypes(); // elide unions with null
if ((types.size() == 2)) {
if (NULL_SCHEMA.equals(types.get(0))) {
return getWrapper(types.get(1));
} else if (NULL_SCHEMA.equals(types.get(1))) {
return getWrapper(types.get(0));
}
}
return Object.class;
> Minor performance enhancement
> -----------------------------
>
> Key: AVRO-1607
> URL: https://issues.apache.org/jira/browse/AVRO-1607
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.8.0
> Reporter: Zoltan Farkas
> Priority: Minor
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> In SpecificData.getClass, line 164:
> {code}
> case UNION:
> List<Schema> types = schema.getTypes(); // elide unions with null
> if ((types.size() == 2) && types.contains(NULL_SCHEMA))
> return getWrapper(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 :
> 0));
> return Object.class;
> {code}
> can be written more efficiently as:
> {code}
> case UNION:
> List<Schema> types = schema.getTypes(); // elide unions with null
> if ((types.size() == 2)) {
> if (NULL_SCHEMA.equals(types.get(0))) {
> return getWrapper(types.get(1));
> } else if (NULL_SCHEMA.equals(types.get(1))) {
> return getWrapper(types.get(0));
> }
> }
> return Object.class;
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)