Package org.apache.lucene.util
Class BytesRefArray
java.lang.Object
org.apache.lucene.util.BytesRefArray
A simple append only random-access
BytesRef
array that stores full copies of the appended
bytes in a ByteBlockPool
.
Note: This class is not Thread-Safe!
- WARNING: This API is experimental and might change in incompatible ways in the next release.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An extension ofBytesRefIterator
that allows retrieving the index of the current elementstatic final class
Used to iterate the elements of an array in a given order. -
Constructor Summary
ConstructorsConstructorDescriptionBytesRefArray
(Counter bytesUsed) Creates a newBytesRefArray
with a counter to track allocated bytes -
Method Summary
Modifier and TypeMethodDescriptionint
Appends a copy of the givenBytesRef
to thisBytesRefArray
.void
clear()
Clears thisBytesRefArray
get
(BytesRefBuilder spare, int index) Returns the n'th element of thisBytesRefArray
iterator()
sugar foriterator(Comparator)
with anull
comparatoriterator
(Comparator<BytesRef> comp) Returns aBytesRefIterator
with point in time semantics.iterator
(BytesRefArray.SortState sortState) Returns anBytesRefArray.IndexedBytesRefIterator
with point in time semantics.int
size()
Returns the current size of thisBytesRefArray
sort
(Comparator<BytesRef> comp, IntBinaryOperator tieComparator) Returns aBytesRefArray.SortState
representing the order of elements in this array.
-
Constructor Details
-
BytesRefArray
Creates a newBytesRefArray
with a counter to track allocated bytes
-
-
Method Details
-
clear
public void clear()Clears thisBytesRefArray
-
append
Appends a copy of the givenBytesRef
to thisBytesRefArray
.- Parameters:
bytes
- the bytes to append- Returns:
- the index of the appended bytes
-
size
public int size()Returns the current size of thisBytesRefArray
- Returns:
- the current size of this
BytesRefArray
-
get
Returns the n'th element of thisBytesRefArray
- Parameters:
spare
- a spareBytesRef
instanceindex
- the elements index to retrieve- Returns:
- the n'th element of this
BytesRefArray
-
sort
Returns aBytesRefArray.SortState
representing the order of elements in this array. This is a non-destructive operation. -
iterator
sugar foriterator(Comparator)
with anull
comparator -
iterator
Returns aBytesRefIterator
with point in time semantics. The iterator provides access to all so far appendedBytesRef
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.
-
iterator
Returns anBytesRefArray.IndexedBytesRefIterator
with point in time semantics. The iterator provides access to all so far appendedBytesRef
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.
-