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.
@lucene.internal
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public sealed class BytesRefHash : IDisposable
Constructors
Name | Description |
---|---|
BytesRefHash() | Creates a new BytesRefHash with a ByteBlockPool using a ByteBlockPool.DirectAllocator. |
BytesRefHash(ByteBlockPool) | Creates a new BytesRefHash |
BytesRefHash(ByteBlockPool, Int32, BytesRefHash.BytesStartArray) | Creates a new BytesRefHash |
Fields
Name | Description |
---|---|
DEFAULT_CAPACITY |
Properties
Name | Description |
---|---|
Count | Returns the number of BytesRef values in this BytesRefHash. NOTE: This was size() in Lucene. |
Methods
Name | Description |
---|---|
Add(BytesRef) | Adds a new BytesRef |
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). |
ByteStart(Int32) | Returns the bytesStart offset into the internally used
ByteBlockPool for the given |
Clear() | |
Clear(Boolean) | |
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. |
Dispose() | Closes the BytesRefHash and releases all internally used memory |
Find(BytesRef) | Returns the id of the given BytesRef. |
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) |
Reinit() | Reinitializes the BytesRefHash after a previous Clear() call. If Clear() has not been called previously this method has no effect. |
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. |