Package org.apache.hadoop.util
Class ChunkedArrayList<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
org.apache.hadoop.util.ChunkedArrayList<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>
Simplified List implementation which stores elements as a list
of chunks, each chunk having a maximum size. This improves over
using an ArrayList in that creating a large list will never require
a large amount of contiguous heap space -- thus reducing the likelihood
of triggering a CMS compaction pause due to heap fragmentation.
The first chunks allocated are small, but each additional chunk is
50% larger than the previous, ramping up to a configurable maximum
chunk size. Reasonable defaults are provided which should be a good
balance between not making any large allocations while still retaining
decent performance.
This currently only supports a small subset of List operations --
namely addition and iteration.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Constructor Details
-
ChunkedArrayList
public ChunkedArrayList() -
ChunkedArrayList
public ChunkedArrayList(int initialChunkCapacity, int maxChunkSize) - Parameters:
initialChunkCapacity- the capacity of the first chunk to be allocatedmaxChunkSize- the maximum size of any chunk allocated
-
-
Method Details
-
iterator
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Overrides:
addin classAbstractList<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- Overrides:
clearin classAbstractList<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<T>
-
get
-