1)  I think the intent was to support avro arrays with more than 2 billion 
elements eventually.  Additionally the underlying serialized array size in the 
avro spec is a long, not an int.
2)  We could add something to get items by index but it could only work on 
small arrays that are not streamed.  I don't think the Generic interface 
supports streaming large arrays yet anyway.

Generally, most users will loop over an array using the Java 5 syntax that 
hides the iterator creation and get() call:

GenericArray<SomeType> array;

for (SomeType item : array) {
  doSomething(item);
}

Rather than something like
for (i = 0; i < size; i++) {
  SomeType item = array.get(i);
  doSomething(item);
}

-Scott


-----Original Message-----
From: Jeff Hammerbacher [mailto:[email protected]] 
Sent: Wednesday, May 19, 2010 6:16 PM
To: [email protected]
Subject: Two questions about GenericArray in the Java implementation

1) Why does size() return a long instead of an int? java.util.List, for
example, returns an int. Not returning an int leads to a lot of lint.
2) Why is there no get(index i) method? I can get an iterator and
continually call next(), but sometimes you want to look up a single element
by index.

My apologies if these are dumb questions; I know very little about Java.

Thanks,
Jeff

Reply via email to