|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.ByteBlockPool
public final class ByteBlockPool
Class that Posting and PostingVector use to write byte streams into shared fixed-size byte[] arrays. The idea is to allocate slices of increasing lengths For example, the first slice is 5 bytes, the next slice is 14, etc. We start by writing our bytes into the first 5 bytes. When we hit the end of the slice, we allocate the next slice and then write the address of the new slice into the last 4 bytes of the previous slice (the "forwarding address"). Each slice is filled with 0's initially, and we mark the end with a non-zero byte. This way the methods that are writing into the slice don't need to record its length and instead allocate a new slice once they hit a non-zero byte.
Nested Class Summary | |
---|---|
static class |
ByteBlockPool.Allocator
Abstract class for allocating and freeing byte blocks. |
static class |
ByteBlockPool.DirectAllocator
A simple ByteBlockPool.Allocator that never recycles. |
static class |
ByteBlockPool.DirectTrackingAllocator
A simple ByteBlockPool.Allocator that never recycles, but
tracks how much total RAM is in use. |
Field Summary | |
---|---|
byte[] |
buffer
Current head buffer |
byte[][] |
buffers
|
static int |
BYTE_BLOCK_MASK
|
static int |
BYTE_BLOCK_SHIFT
|
static int |
BYTE_BLOCK_SIZE
|
int |
byteOffset
Current head offset |
int |
byteUpto
Where we are in head buffer |
static int |
FIRST_LEVEL_SIZE
|
static int[] |
levelSizeArray
|
static int[] |
nextLevelArray
|
Constructor Summary | |
---|---|
ByteBlockPool(ByteBlockPool.Allocator allocator)
|
Method Summary | |
---|---|
int |
allocSlice(byte[] slice,
int upto)
|
void |
copy(BytesRef bytes)
Copies the given BytesRef at the current positions (
byteUpto across buffer boundaries |
BytesRef |
copyFrom(BytesRef bytes)
|
BytesRef |
deref(BytesRef bytes)
Dereferences the byte block according to BytesRef offset. |
void |
dropBuffersAndReset()
|
int |
newSlice(int size)
|
void |
nextBuffer()
|
void |
reset()
|
BytesRef |
setBytesRef(BytesRef term,
int textStart)
|
void |
writePool(DataOutput out)
Writes the pools content to the given DataOutput |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BYTE_BLOCK_SHIFT
public static final int BYTE_BLOCK_SIZE
public static final int BYTE_BLOCK_MASK
public byte[][] buffers
public int byteUpto
public byte[] buffer
public int byteOffset
public static final int[] nextLevelArray
public static final int[] levelSizeArray
public static final int FIRST_LEVEL_SIZE
Constructor Detail |
---|
public ByteBlockPool(ByteBlockPool.Allocator allocator)
Method Detail |
---|
public void dropBuffersAndReset()
public void reset()
public void nextBuffer()
public int newSlice(int size)
public int allocSlice(byte[] slice, int upto)
public final BytesRef setBytesRef(BytesRef term, int textStart)
public final BytesRef deref(BytesRef bytes)
BytesRef
offset. The offset
is interpreted as the absolute offset into the ByteBlockPool
.
public final void copy(BytesRef bytes)
BytesRef
at the current positions (
byteUpto
across buffer boundaries
public final BytesRef copyFrom(BytesRef bytes)
public final void writePool(DataOutput out) throws IOException
DataOutput
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |