Package org.apache.lucene.search.suggest
Class BytesRefArray
java.lang.Object
org.apache.lucene.search.suggest.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!-
Constructor Summary
ConstructorsConstructorDescriptionBytesRefArray(Counter bytesUsed) Creates a newBytesRefArraywith a counter to track allocated bytes -
Method Summary
Modifier and TypeMethodDescriptionintAppends a copy of the givenBytesRefto thisBytesRefArray.voidclear()Clears thisBytesRefArrayReturns the n'th element of thisBytesRefArrayiterator()sugar foriterator(Comparator)with anullcomparatoriterator(Comparator<BytesRef> comp) Returns aBytesRefIteratorwith point in time semantics.intsize()Returns the current size of thisBytesRefArray
-
Constructor Details
-
BytesRefArray
Creates a newBytesRefArraywith a counter to track allocated bytes
-
-
Method Details
-
clear
public void clear()Clears thisBytesRefArray -
append
Appends a copy of the givenBytesRefto 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 spareBytesRefinstanceindex- the elements index to retrieve- Returns:
- the n'th element of this
BytesRefArray
-
iterator
sugar foriterator(Comparator)with anullcomparator -
iterator
Returns a
BytesRefIteratorwith point in time semantics. The iterator provides access to all so far appendedBytesRefinstances.If a non
nullComparatoris 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.
-