Show / Hide Table of Contents

    Class BytesRefHash

    BytesRefHash is a special purpose hash-map like data-structure optimized for BytesRef instances. BytesRefHash maintains mappings of byte arrays to ids (Map<BytesRef,int>) storing the hashed bytes efficiently in continuous storage. The mapping to the id is encapsulated inside BytesRefHash and is guaranteed to be increased for each added BytesRef.

    Note: The maximum capacity BytesRef instance passed to Add(BytesRef) must not be longer than BYTE_BLOCK_SIZE-2. The internal storage is limited to 2GB total byte storage.

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

    Constructors

    | Improve this Doc View Source

    BytesRefHash()

    Creates a new BytesRefHash with a ByteBlockPool using a ByteBlockPool.DirectAllocator.

    Declaration
    public BytesRefHash()
    | Improve this Doc View Source

    BytesRefHash(ByteBlockPool)

    Creates a new BytesRefHash

    Declaration
    public BytesRefHash(ByteBlockPool pool)
    Parameters
    Type Name Description
    ByteBlockPool pool
    | Improve this Doc View Source

    BytesRefHash(ByteBlockPool, Int32, BytesRefHash.BytesStartArray)

    Creates a new BytesRefHash

    Declaration
    public BytesRefHash(ByteBlockPool pool, int capacity, BytesRefHash.BytesStartArray bytesStartArray)
    Parameters
    Type Name Description
    ByteBlockPool pool
    System.Int32 capacity
    BytesRefHash.BytesStartArray bytesStartArray

    Fields

    | Improve this Doc View Source

    DEFAULT_CAPACITY

    Declaration
    public const int DEFAULT_CAPACITY = null
    Field Value
    Type Description
    System.Int32

    Properties

    | Improve this Doc View Source

    Count

    Returns the number of BytesRef values in this BytesRefHash.

    NOTE: This was size() in Lucene.

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

    The number of BytesRef values in this BytesRefHash.

    Methods

    | Improve this Doc View Source

    Add(BytesRef)

    Adds a new BytesRef

    Declaration
    public int Add(BytesRef bytes)
    Parameters
    Type Name Description
    BytesRef bytes

    The bytes to hash

    Returns
    Type Description
    System.Int32

    The id the given bytes are hashed if there was no mapping for the given bytes, otherwise (-(id)-1). this guarantees that the return value will always be >= 0 if the given bytes haven't been hashed before.

    Exceptions
    Type Condition
    BytesRefHash.MaxBytesLengthExceededException

    if the given bytes are > 2 + BYTE_BLOCK_SIZE

    | Improve this Doc View Source

    AddByPoolOffset(Int32)

    Adds a "arbitrary" int offset instead of a BytesRef term. This is used in the indexer to hold the hash for term vectors, because they do not redundantly store the byte[] term directly and instead reference the byte[] term already stored by the postings BytesRefHash. See Lucene.Net.Index.TermsHashPerField.Add(System.Int32).

    Declaration
    public int AddByPoolOffset(int offset)
    Parameters
    Type Name Description
    System.Int32 offset
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    ByteStart(Int32)

    Returns the bytesStart offset into the internally used ByteBlockPool for the given bytesID

    Declaration
    public int ByteStart(int bytesID)
    Parameters
    Type Name Description
    System.Int32 bytesID

    The id to look up

    Returns
    Type Description
    System.Int32

    The bytesStart offset into the internally used ByteBlockPool for the given id

    | Improve this Doc View Source

    Clear()

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

    Clear(Boolean)

    Clears the BytesRef which maps to the given BytesRef

    Declaration
    public void Clear(bool resetPool)
    Parameters
    Type Name Description
    System.Boolean resetPool
    | Improve this Doc View Source

    Compact()

    Returns the ids array in arbitrary order. Valid ids start at offset of 0 and end at a limit of Count - 1

    Note: this is a destructive operation. Clear() must be called in order to reuse this BytesRefHash instance.

    Declaration
    public int[] Compact()
    Returns
    Type Description
    System.Int32[]
    | Improve this Doc View Source

    Dispose()

    Closes the BytesRefHash and releases all internally used memory

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

    Find(BytesRef)

    Returns the id of the given BytesRef.

    Declaration
    public int Find(BytesRef bytes)
    Parameters
    Type Name Description
    BytesRef bytes

    The bytes to look for

    Returns
    Type Description
    System.Int32

    The id of the given bytes, or -1 if there is no mapping for the given bytes.

    | Improve this Doc View Source

    Get(Int32, BytesRef)

    Populates and returns a BytesRef with the bytes for the given bytesID.

    Note: the given bytesID must be a positive integer less than the current size (Count)

    Declaration
    public BytesRef Get(int bytesID, BytesRef ref)
    Parameters
    Type Name Description
    System.Int32 bytesID

    The id

    BytesRef ref

    The BytesRef to populate

    Returns
    Type Description
    BytesRef

    The given BytesRef instance populated with the bytes for the given bytesID

    | Improve this Doc View Source

    Reinit()

    Reinitializes the BytesRefHash after a previous Clear() call. If Clear() has not been called previously this method has no effect.

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

    Sort(IComparer<BytesRef>)

    Returns the values array sorted by the referenced byte values.

    Note: this is a destructive operation. Clear() must be called in order to reuse this BytesRefHash instance.

    Declaration
    public int[] Sort(IComparer<BytesRef> comp)
    Parameters
    Type Name Description
    IComparer<BytesRef> comp

    The IComparer<BytesRef> used for sorting

    Returns
    Type Description
    System.Int32[]
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)