public final class BytesRefHash
extends java.lang.Object
BigArrays
, hashes are cached for faster
re-hashing and capacity is always a multiple of 2 for faster identification of buckets.
This class is not thread-safe.Constructor and Description |
---|
BytesRefHash(long capacity,
BigArrays bigArrays) |
BytesRefHash(long capacity,
float maxLoadFactor,
BigArrays bigArrays) |
Modifier and Type | Method and Description |
---|---|
long |
add(org.apache.lucene.util.BytesRef key)
Sugar to
add(key, key.hashCode() . |
long |
add(org.apache.lucene.util.BytesRef key,
int code)
Try to add
key . |
long |
capacity()
Return the number of allocated slots to store this hash table.
|
void |
close() |
long |
find(org.apache.lucene.util.BytesRef key)
Sugar for
find(key, key.hashCode() |
long |
find(org.apache.lucene.util.BytesRef key,
int code)
Get the id associated with
key |
org.apache.lucene.util.BytesRef |
get(long id,
org.apache.lucene.util.BytesRef dest)
Return the key at
0 <= index <= capacity() . |
protected void |
grow() |
long |
id(long index)
Get the id associated with key at
0 <= index <= capacity() or -1 if this slot is unused. |
protected long |
id(long index,
long id) |
protected void |
removeAndAdd(long index)
Remove the entry at the given index and add it back
|
protected void |
resize(long capacity)
Resize to the given capacity.
|
long |
size()
Return the number of longs in this hash table.
|
protected boolean |
used(long bucket) |
public BytesRefHash(long capacity, BigArrays bigArrays)
public BytesRefHash(long capacity, float maxLoadFactor, BigArrays bigArrays)
public org.apache.lucene.util.BytesRef get(long id, org.apache.lucene.util.BytesRef dest)
0 <= index <= capacity()
. The result is undefined if the slot is unused.
Beware that the content of the BytesRef
may become invalid as soon as close()
is called
public long find(org.apache.lucene.util.BytesRef key, int code)
key
public long find(org.apache.lucene.util.BytesRef key)
find(key, key.hashCode()
public long add(org.apache.lucene.util.BytesRef key, int code)
key
. Return its newly allocated id if it wasn't in the hash table yet, or -1-id
if it was already present in the hash table.public long add(org.apache.lucene.util.BytesRef key)
add(key, key.hashCode()
.protected void removeAndAdd(long index)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface Releasable
public long id(long index)
0 <= index <= capacity()
or -1 if this slot is unused.protected final long id(long index, long id)
protected void resize(long capacity)
protected boolean used(long bucket)
public long capacity()
public long size()
protected final void grow()