Package org.apache.lucene.search.suggest
Class BytesRefArray
- java.lang.Object
-
- org.apache.lucene.search.suggest.BytesRefArray
-
public final class BytesRefArray extends java.lang.Object
A simple append only random-accessBytesRef
array 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 newBytesRefArray
with a counter to track allocated bytes
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
append(BytesRef bytes)
Appends a copy of the givenBytesRef
to thisBytesRefArray
.void
clear()
Clears thisBytesRefArray
BytesRef
get(BytesRef spare, int index)
Returns the n'th element of thisBytesRefArray
BytesRefIterator
iterator()
sugar foriterator(Comparator)
with anull
comparatorBytesRefIterator
iterator(java.util.Comparator<BytesRef> comp)
Returns aBytesRefIterator
with point in time semantics.int
size()
Returns the current size of thisBytesRefArray
-
-
-
Constructor Detail
-
BytesRefArray
public BytesRefArray(Counter bytesUsed)
Creates a newBytesRefArray
with 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 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
public BytesRef get(BytesRef spare, int index)
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
-
iterator
public BytesRefIterator iterator()
sugar foriterator(Comparator)
with anull
comparator
-
iterator
public BytesRefIterator iterator(java.util.Comparator<BytesRef> comp)
Returns a
BytesRefIterator
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.
-
-