Show / Hide Table of Contents

    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.

    This is a Lucene.NET INTERNAL API, use at your own risk
    Inheritance
    System.Object
    ByteBlockPool
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class ByteBlockPool : object

    Constructors

    | Improve this Doc View Source

    ByteBlockPool(ByteBlockPool.Allocator)

    Declaration
    public ByteBlockPool(ByteBlockPool.Allocator allocator)
    Parameters
    Type Name Description
    ByteBlockPool.Allocator allocator

    Fields

    | Improve this Doc View Source

    BYTE_BLOCK_MASK

    Declaration
    public static readonly int BYTE_BLOCK_MASK
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    BYTE_BLOCK_SHIFT

    Declaration
    public static readonly int BYTE_BLOCK_SHIFT
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    BYTE_BLOCK_SIZE

    Declaration
    public static readonly int BYTE_BLOCK_SIZE
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    FIRST_LEVEL_SIZE

    The first level size for new slices

    Declaration
    public static readonly int FIRST_LEVEL_SIZE
    Field Value
    Type Description
    System.Int32
    See Also
    NewSlice(Int32)
    | Improve this Doc View Source

    LEVEL_SIZE_ARRAY

    An array holding the level sizes for byte slices.

    Declaration
    public static readonly int[] LEVEL_SIZE_ARRAY
    Field Value
    Type Description
    System.Int32[]
    | Improve this Doc View Source

    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
    System.Int32[]

    Properties

    | Improve this Doc View Source

    Buffer

    Current head buffer

    Declaration
    public byte[] Buffer { get; set; }
    Property Value
    Type Description
    System.Byte[]
    | Improve this Doc View Source

    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
    System.Byte[][]
    | Improve this Doc View Source

    ByteOffset

    Current head offset

    Declaration
    public int ByteOffset { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    ByteUpto

    Where we are in head buffer

    Declaration
    public int ByteUpto { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    AllocSlice(Byte[], Int32)

    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
    System.Byte[] slice
    System.Int32 upto
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    NewSlice(Int32)

    Allocates a new slice with the given size.

    Declaration
    public int NewSlice(int size)
    Parameters
    Type Name Description
    System.Int32 size
    Returns
    Type Description
    System.Int32
    See Also
    FIRST_LEVEL_SIZE
    | Improve this Doc View Source

    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()
    | Improve this Doc View Source

    ReadBytes(Int64, Byte[], Int32, Int32)

    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
    System.Int64 offset
    System.Byte[] bytes
    System.Int32 off
    System.Int32 length
    | Improve this Doc View Source

    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[][], Int32, Int32). Calling NextBuffer() is not needed after reset.

    Declaration
    public void Reset()
    | Improve this Doc View Source

    Reset(Boolean, Boolean)

    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
    System.Boolean zeroFillBuffers

    if true the buffers are filled with 0. this should be set to true if this pool is used with slices.

    System.Boolean reuseFirst

    if true the first buffer will be reused and calling NextBuffer() is not needed after reset if the block pool was used before ie. NextBuffer() was called before.

    | Improve this Doc View Source

    SetBytesRef(BytesRef, Int32)

    Declaration
    public void SetBytesRef(BytesRef term, int textStart)
    Parameters
    Type Name Description
    BytesRef term
    System.Int32 textStart
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)