Package org.apache.lucene.search.suggest
Class BytesRefArray
- java.lang.Object
-
- org.apache.lucene.search.suggest.BytesRefArray
-
public final class BytesRefArray extends java.lang.ObjectA simple append only random-accessBytesRefarray that stores full copies of the appended bytes in aByteBlockPool. Note: This class is not Thread-Safe!
-
-
Constructor Summary
Constructors Constructor Description BytesRefArray(Counter bytesUsed)Creates a newBytesRefArraywith a counter to track allocated bytes
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intappend(BytesRef bytes)Appends a copy of the givenBytesRefto thisBytesRefArray.voidclear()Clears thisBytesRefArrayBytesRefget(BytesRef spare, int index)Returns the n'th element of thisBytesRefArrayBytesRefIteratoriterator()sugar foriterator(Comparator)with anullcomparatorBytesRefIteratoriterator(java.util.Comparator<BytesRef> comp)Returns aBytesRefIteratorwith point in time semantics.intsize()Returns the current size of thisBytesRefArray
-
-
-
Constructor Detail
-
BytesRefArray
public BytesRefArray(Counter bytesUsed)
Creates a newBytesRefArraywith a counter to track allocated bytes
-
-
Method Detail
-
clear
public void clear()
Clears thisBytesRefArray
-
append
public int append(BytesRef bytes)
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
public BytesRef get(BytesRef spare, int index)
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
public BytesRefIterator iterator()
sugar foriterator(Comparator)with anullcomparator
-
iterator
public BytesRefIterator iterator(java.util.Comparator<BytesRef> comp)
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.
-
-