C# Класс Lucene.Net.Util.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 ByteBlockPool#BYTE_BLOCK_SIZE-2. The internal storage is limited to 2GB total byte storage.

@lucene.internal
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Add ( BytesRef bytes ) : int

Adds a new BytesRef

AddByPoolOffset ( int offset ) : int

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 add(int textStart) in TermsHashPerField.

ByteStart ( int bytesID ) : int

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

BytesRefHash ( ) : System

Creates a new BytesRefHash with a ByteBlockPool using a DirectAllocator.

BytesRefHash ( Lucene.Net.Util.ByteBlockPool pool ) : System

Creates a new BytesRefHash

BytesRefHash ( Lucene.Net.Util.ByteBlockPool pool, int capacity, BytesStartArray bytesStartArray ) : System

Creates a new BytesRefHash

Clear ( ) : void
Clear ( bool resetPool ) : void

Clears the BytesRef which maps to the given BytesRef

Close ( ) : void

Closes the BytesRefHash and releases all internally used memory

Compact ( ) : int[]

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

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

Find ( BytesRef bytes ) : int

Returns the id of the given BytesRef.

Get ( int bytesID, BytesRef @ref ) : 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 (#size())

Reinit ( ) : void

reinitializes the BytesRefHash after a previous #clear() call. If #clear() has not been called previously this method has no effect.

Size ( ) : int

Returns the number of BytesRef values in this BytesRefHash.

Sort ( IComparer comp ) : int[]

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.

Приватные методы

Метод Описание
DoHash ( byte bytes, int offset, int length ) : int
Equals ( int id, BytesRef b ) : bool
FindHash ( BytesRef bytes ) : int
Rehash ( int newSize, bool hashOnData ) : void

Called when hash is too small (> 50% occupied) or too large (< 20% occupied).

Shrink ( int targetSize ) : bool

Описание методов

Add() публичный Метод

Adds a new BytesRef
/// if the given bytes are > 2 + ///
public Add ( BytesRef bytes ) : int
bytes BytesRef /// the bytes to hash
Результат int

AddByPoolOffset() публичный Метод

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 add(int textStart) in TermsHashPerField.
public AddByPoolOffset ( int offset ) : int
offset int
Результат int

ByteStart() публичный Метод

Returns the bytesStart offset into the internally used ByteBlockPool for the given bytesID
public ByteStart ( int bytesID ) : int
bytesID int /// the id to look up
Результат int

BytesRefHash() публичный Метод

Creates a new BytesRefHash with a ByteBlockPool using a DirectAllocator.
public BytesRefHash ( ) : System
Результат System

BytesRefHash() публичный Метод

Creates a new BytesRefHash
public BytesRefHash ( Lucene.Net.Util.ByteBlockPool pool ) : System
pool Lucene.Net.Util.ByteBlockPool
Результат System

BytesRefHash() публичный Метод

Creates a new BytesRefHash
public BytesRefHash ( Lucene.Net.Util.ByteBlockPool pool, int capacity, BytesStartArray bytesStartArray ) : System
pool Lucene.Net.Util.ByteBlockPool
capacity int
bytesStartArray BytesStartArray
Результат System

Clear() публичный Метод

public Clear ( ) : void
Результат void

Clear() публичный Метод

Clears the BytesRef which maps to the given BytesRef
public Clear ( bool resetPool ) : void
resetPool bool
Результат void

Close() публичный Метод

Closes the BytesRefHash and releases all internally used memory
public Close ( ) : void
Результат void

Compact() публичный Метод

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

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

public Compact ( ) : int[]
Результат int[]

Find() публичный Метод

Returns the id of the given BytesRef.
public Find ( BytesRef bytes ) : int
bytes BytesRef /// the bytes to look for ///
Результат int

Get() публичный Метод

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 (#size())

public Get ( int bytesID, BytesRef @ref ) : BytesRef
bytesID int /// the id
@ref BytesRef
Результат BytesRef

Reinit() публичный Метод

reinitializes the BytesRefHash after a previous #clear() call. If #clear() has not been called previously this method has no effect.
public Reinit ( ) : void
Результат void

Size() публичный Метод

Returns the number of BytesRef values in this BytesRefHash.
public Size ( ) : int
Результат int

Sort() публичный Метод

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.

public Sort ( IComparer comp ) : int[]
comp IComparer /// the used for sorting
Результат int[]