Replacing with ArrayDeque wouldn't be straight forward since it implements Deque interface where there is no method for accessing given index.
ArrayDeque provides remove by Object: public boolean remove(Object o) { return removeFirstOccurrence(o); After the removal, add() or offer() only inserts at the end of the deque. FYI On Sun, Mar 11, 2018 at 7:33 AM, Chia-Ping Tsai <chia7...@apache.org> wrote: > > LL copy is fairly slow and likely loses us any gains. Also, I'm a little > > dubious on the use of LL given that we support a replaceAtIndex which > will > > be much faster in an array. > > > > Can we improve by using an ArrayDeque? > Does ArrayDeque support to change element by arbitrary index? If not, it > not easy to change the impl by one line since the replaceAtIndex() need to > change the element in pipeline. > > BTW, could we change the impl of "readOnlyCopy" from LinkedList to > ArrayList? Most ops to readOnlyCopy are iteration, and the getLast can be > replaced by size() and get(index). > > On 2018/03/10 20:12:01, Mike Drob <mad...@cloudera.com> wrote: > > Hi devs, > > > > I was reading through HBASE-17434 trying to understand why we have two > > linked lists in compaction pipeline and I'm having trouble following the > > conversation there, especially since it seems intertwined with > HBASE-17379 > > and jumps back and forth a few times. > > > > It looks like we are implementing our own copy-on-write list, and there > is > > a claim that addFirst is faster on a LinkedList than an array based > list. I > > am concerned about the LL copy in pushHead - even if addFirst is faster, > a > > LL copy is fairly slow and likely loses us any gains. Also, I'm a little > > dubious on the use of LL given that we support a replaceAtIndex which > will > > be much faster in an array. > > > > Can we improve by using an ArrayDeque? > > > > Eschar, Anastasia, WDYT? > > > > Thanks, > > Mike > > > > Some observations about performance - > > https://stuartmarks.wordpress.com/2015/12/18/some-java-list-benchmarks/ > > >