avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-637) GenericArray should implement Collection
Date Sat, 28 Aug 2010 03:28:53 GMT

    [ https://issues.apache.org/jira/browse/AVRO-637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903762#action_12903762
] 

Doug Cutting commented on AVRO-637:
-----------------------------------

Scott> Good point, another change in 1.4 along these lines doesn't add much incremental
work to upgrade.

Great.  So we're agreed that this should go into 1.4.0.

So the questions to resolve are:
 - what types should we accept at runtime; and
 - what type should generated code declare

At runtime I think it's useful to accept the most general interface we can, so that means
Collection, as we require just iterator(), size(), clear() and add(T) in order to read &
write data.

As for generated declarations, I prefer to declare things to be the most general type required,
again, in this case Collection.  The only downside I see to this is that folks who want to
randomly access a value they receive will not be able to without casting or somesuch, as get(int)
is a List method, not a Collection method.  But if we declare them as List they'll be unable
to pass other types of collections.  HDFS RPCs do pass Set implementations over RPC.  With
mechanisms like reflection's "java-class" annotation the set's class can be preserved by the
DatumReader.  And the runtime will support arbitrary Collections.  So it seems a shame to
not permit them in specific data.  So, on the whole, I lean towards Collection here too, but
would be willing to go with List if others feel strongly.

> GenericArray should implement Collection
> ----------------------------------------
>
>                 Key: AVRO-637
>                 URL: https://issues.apache.org/jira/browse/AVRO-637
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Doug Cutting
>            Assignee: Doug Cutting
>             Fix For: 1.5.0
>
>         Attachments: AVRO-637.patch, AVRO-637.patch
>
>
> It would be nice if Avro arrays were better integrated with Java collections.  The GenericArray
interface permits array element reuse, which is awkward with java.util.Collection.  But if
GenericArray implemented Collection and the Avro runtime permitted arbitrary Collection implementations
to be passed for Arrays then it would simplify many applications.  The runtime could still
reuse elements if an array implemented GenericArray, so performance would not suffer for applications
that, e.g., loop over a data file, reusing instances.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message