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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public sealed class ByteBlockPool
Constructors
ByteBlockPool(Allocator)
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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public ByteBlockPool(ByteBlockPool.Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
ByteBlockPool.Allocator | allocator |
Fields
BYTE_BLOCK_MASK
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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static readonly int BYTE_BLOCK_MASK
Field Value
Type | Description |
---|---|
int |
BYTE_BLOCK_SHIFT
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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static readonly int BYTE_BLOCK_SHIFT
Field Value
Type | Description |
---|---|
int |
BYTE_BLOCK_SIZE
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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static readonly int BYTE_BLOCK_SIZE
Field Value
Type | Description |
---|---|
int |
FIRST_LEVEL_SIZE
The first level size for new slices
Declaration
public static readonly int FIRST_LEVEL_SIZE
Field Value
Type | Description |
---|---|
int |
See Also
LEVEL_SIZE_ARRAY
An array holding the level sizes for byte slices.
Declaration
public static readonly int[] LEVEL_SIZE_ARRAY
Field Value
Type | Description |
---|---|
int[] |
NEXT_LEVEL_ARRAY
An array holding the offset into the LEVEL_SIZE_ARRAY to quickly navigate to the next slice level.
Declaration
public static readonly int[] NEXT_LEVEL_ARRAY
Field Value
Type | Description |
---|---|
int[] |
Properties
Buffer
Current head buffer
Declaration
public byte[] Buffer { get; set; }
Property Value
Type | Description |
---|---|
byte[] |
Buffers
Array of buffers currently used in the pool. Buffers are allocated if needed don't modify this outside of this class.
Declaration
public byte[][] Buffers { get; set; }
Property Value
Type | Description |
---|---|
byte[][] |
ByteOffset
Current head offset
Declaration
public int ByteOffset { get; set; }
Property Value
Type | Description |
---|---|
int |
ByteUpto
Where we are in head buffer
Declaration
public int ByteUpto { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
AllocSlice(byte[], int)
Creates a new byte slice with the given starting size and returns the slices offset in the pool.
Declaration
public int AllocSlice(byte[] slice, int upto)
Parameters
Type | Name | Description |
---|---|---|
byte[] | slice | |
int | upto |
Returns
Type | Description |
---|---|
int |
Append(BytesRef)
Appends the bytes in the provided BytesRef at the current position.
Declaration
public void Append(BytesRef bytes)
Parameters
Type | Name | Description |
---|---|---|
BytesRef | bytes |
NewSlice(int)
Allocates a new slice with the given size.
Declaration
public int NewSlice(int size)
Parameters
Type | Name | Description |
---|---|---|
int | size |
Returns
Type | Description |
---|---|
int |
See Also
NextBuffer()
Advances the pool to its next buffer. This method should be called once after the constructor to initialize the pool. In contrast to the constructor a Reset() call will advance the pool to its first buffer immediately.
Declaration
public void NextBuffer()
ReadBytes(long, byte[], int, int)
Reads bytes bytes out of the pool starting at the given offset with the given
length into the given byte array at offset off
.
Note: this method allows to copy across block boundaries.
Declaration
public void ReadBytes(long offset, byte[] bytes, int off, int length)
Parameters
Type | Name | Description |
---|---|---|
long | offset | |
byte[] | bytes | |
int | off | |
int | length |
Reset()
Resets the pool to its initial state reusing the first buffer and fills all
buffers with 0
bytes before they reused or passed to
RecycleByteBlocks(byte[][], int, int). Calling
NextBuffer() is not needed after reset.
Declaration
public void Reset()
Reset(bool, bool)
Expert: Resets the pool to its initial state reusing the first buffer. Calling NextBuffer() is not needed after reset.
Declaration
public void Reset(bool zeroFillBuffers, bool reuseFirst)
Parameters
Type | Name | Description |
---|---|---|
bool | zeroFillBuffers | if |
bool | reuseFirst | if |
SetBytesRef(BytesRef, int)
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.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public void SetBytesRef(BytesRef term, int textStart)
Parameters
Type | Name | Description |
---|---|---|
BytesRef | term | |
int | textStart |