- java.lang.Object
-
- org.apache.lucene.util.BytesRefBlockPool
-
- All Implemented Interfaces:
Accountable
public class BytesRefBlockPool extends java.lang.Object implements Accountable
Represents a logical list of ByteRef backed by aByteBlockPool
. It uses up to two bytes to record the length of the BytesRef followed by the actual bytes. They can be read using the start position returned when they are appended.The
BytesRef
is written so it never crosses theByteBlockPool.BYTE_BLOCK_SIZE
boundary. The limit of the largestBytesRef
is thereforeByteBlockPool.BYTE_BLOCK_SIZE
-2 bytes.
-
-
Field Summary
Fields Modifier and Type Field Description private static long
BASE_RAM_BYTES
private ByteBlockPool
byteBlockPool
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description BytesRefBlockPool()
BytesRefBlockPool(ByteBlockPool byteBlockPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addBytesRef(BytesRef bytes)
Add a term returning the start position on the underlyingByteBlockPool
.(package private) boolean
equals(int start, BytesRef b)
Computes the equality between the BytesRef at the start position with the provided BytesRef.void
fillBytesRef(BytesRef term, int start)
Populates the given BytesRef with the term starting at start.(package private) int
hash(int start)
Computes the hash of the BytesRef at the given start.long
ramBytesUsed()
Return the memory usage of this object in bytes.(package private) void
reset()
Reset this buffer to the empty state.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
BASE_RAM_BYTES
private static final long BASE_RAM_BYTES
-
byteBlockPool
private final ByteBlockPool byteBlockPool
-
-
Constructor Detail
-
BytesRefBlockPool
public BytesRefBlockPool()
-
BytesRefBlockPool
public BytesRefBlockPool(ByteBlockPool byteBlockPool)
-
-
Method Detail
-
reset
void reset()
Reset this buffer to the empty state.
-
fillBytesRef
public void fillBytesRef(BytesRef term, int start)
Populates the given BytesRef with the term starting at start.- See Also:
fillBytesRef(BytesRef, int)
-
addBytesRef
public int addBytesRef(BytesRef bytes)
Add a term returning the start position on the underlyingByteBlockPool
. THis can be used to read back the value usingfillBytesRef(BytesRef, int)
.- See Also:
fillBytesRef(BytesRef, int)
-
hash
int hash(int start)
Computes the hash of the BytesRef at the given start. This is equivalent of doing:BytesRef bytes = new BytesRef(); fillTerm(bytes, start); BytesRefHash.doHash(bytes.bytes, bytes.pos, bytes.len);
It just saves the work of filling the BytesRef.
-
equals
boolean equals(int start, BytesRef b)
Computes the equality between the BytesRef at the start position with the provided BytesRef. This is equivalent of doing:BytesRef bytes = new BytesRef(); fillTerm(bytes, start); Arrays.equals(bytes.bytes, bytes.offset, bytes.offset + length, b.bytes, b.offset, b.offset + b.length);
It just saves the work of filling the BytesRef.
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-
-