public final class BytesRefArray extends Object
BytesRef
array that stores full
copies of the appended bytes in a ByteBlockPool
.
Note: This class is not Thread-Safe!Modifier and Type | Class and Description |
---|---|
static interface |
BytesRefArray.IndexedBytesRefIterator
An extension of
BytesRefIterator that allows retrieving the index of the current element |
static class |
BytesRefArray.SortState
Used to iterate the elements of an array in a given order.
|
Constructor and Description |
---|
BytesRefArray(Counter bytesUsed)
Creates a new
BytesRefArray with a counter to track allocated bytes |
Modifier and Type | Method and Description |
---|---|
int |
append(BytesRef bytes)
Appends a copy of the given
BytesRef to this BytesRefArray . |
void |
clear()
Clears this
BytesRefArray |
BytesRef |
get(BytesRefBuilder spare,
int index)
Returns the n'th element of this
BytesRefArray |
BytesRefIterator |
iterator()
sugar for
iterator(Comparator) with a null comparator |
BytesRefArray.IndexedBytesRefIterator |
iterator(BytesRefArray.SortState sortState)
Returns an
BytesRefArray.IndexedBytesRefIterator with point in time semantics. |
BytesRefIterator |
iterator(Comparator<BytesRef> comp)
Returns a
BytesRefIterator with point in time semantics. |
int |
size()
Returns the current size of this
BytesRefArray |
BytesRefArray.SortState |
sort(Comparator<BytesRef> comp,
IntBinaryOperator tieComparator)
Returns a
BytesRefArray.SortState representing the order of elements in this array. |
public BytesRefArray(Counter bytesUsed)
BytesRefArray
with a counter to track allocated bytespublic void clear()
BytesRefArray
public int append(BytesRef bytes)
BytesRef
to this BytesRefArray
.bytes
- the bytes to appendpublic int size()
BytesRefArray
BytesRefArray
public BytesRef get(BytesRefBuilder spare, int index)
BytesRefArray
spare
- a spare BytesRef
instanceindex
- the elements index to retrieveBytesRefArray
public BytesRefArray.SortState sort(Comparator<BytesRef> comp, IntBinaryOperator tieComparator)
BytesRefArray.SortState
representing the order of elements in this array. This is a non-destructive operation.public BytesRefIterator iterator()
iterator(Comparator)
with a null
comparatorpublic BytesRefIterator iterator(Comparator<BytesRef> comp)
Returns a BytesRefIterator
with point in time semantics. The
iterator provides access to all so far appended BytesRef
instances.
If a non null
Comparator
is provided the iterator will
iterate the byte values in the order specified by the comparator. Otherwise
the order is the same as the values were appended.
This is a non-destructive operation.
public BytesRefArray.IndexedBytesRefIterator iterator(BytesRefArray.SortState sortState)
BytesRefArray.IndexedBytesRefIterator
with point in time semantics. The iterator provides access to all
so far appended BytesRef
instances. If a non-null sortState is specified then the iterator will iterate
the byte values in the order of the sortState; otherwise, the order is the same as the values were appended.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.