Hey Matthias, If you look at implementation of ensureCapacity it reallocates to new internal array, whereas arraylist(int) initially creates new array upfront. Though this is not much difference if you use it initially, but arraylist(int) is cleaner solution for this.
-----Original Message----- From: Matthias J. Sax [mailto:[email protected]] Sent: Sunday, January 03, 2016 12:48 AM To: [email protected] Subject: Re: Adding more constructors in Tuple class Hi, as Values inherits from ArrayList, you can also use .ensureCapacity(int). -Matthias On 01/02/2016 04:41 PM, Nathan Leung wrote: > Is there a use case that requires the first? I thought most people use > Values which has a variadic constructor so you know the length already > anyways. > > The second doesn't map cleanly. If you pass a set, how do you order > the elements in the tuple? You can just pass your collection as a > field in the tuple if that's what you need to do. > On Jan 2, 2016 1:44 AM, "Sachin Pasalkar" > <[email protected]> > wrote: > >> Hi, >> >> Can we add some more constructor in backtype.storm.tuple.Values class >> which are already present in ArrayList class. Some examples are below >> >> >> public Values(int initialCapacity) { >> >> super(initialCapacity); >> >> } >> >> This will help us in some performance management if we know what size >> the list going to be. >> >> >> public Values(Collection<? extends Object> c) { >> >> super(c); >> >> } >> >> >> This will allow us the addling predefined list to values instead of >> manually iterating over it. We cannot use Values(Object... vals) as >> it treat list of element as one element >> >> >> Thanks, >> >> Sachin >> >> >
