xtructure.hashtable package
Submodules
xtructure.hashtable.table module
HashTable data container and public API.
- class xtructure.hashtable.table.HashTable(seed: int, capacity: int, _capacity: int, bucket_size: int, size: int, table: Xtructurable, bucket_fill_levels: Array | ndarray | bool | number, fingerprints: Array | ndarray | bool | number, max_probes: int)[source]
Bases:
objectBucketed Double Hash Table Implementation
Uses double hashing with buckets to resolve collisions.
- bucket_fill_levels: Array | ndarray | bool | number
- bucket_size: int
- static build(dataclass: Xtructurable, seed: int, capacity: int, bucket_size: int = 8, hash_size_multiplier: int = 2, max_probes: int | None = None) HashTable[source]
Initialize a new hash table backed by JAX-friendly storage.
- capacity: int
- fingerprints: Array | ndarray | bool | number
- from_tuple()
- insert(input: Xtructurable) tuple[HashTable, bool, HashIdx][source]
- lookup(input: Xtructurable) tuple[HashIdx, bool][source]
- lookup_bucket(input: Xtructurable) tuple[BucketIdx, bool, Array | ndarray | bool | number][source]
- lookup_parallel(inputs: Xtructurable, filled: Array | ndarray | bool | number | bool = True) tuple[HashIdx, Array | ndarray | bool | number][source]
- max_probes: int
- parallel_insert(inputs: Xtructurable, filled: Array | ndarray | bool | number | bool = None, unique_key: Array | ndarray | bool | number = None)[source]
- replace(**kwargs)
- seed: int
- size: int
- table: Xtructurable
- to_tuple()
Module contents
- class xtructure.hashtable.HashIdx(index: FieldDescriptor(dtype = <class 'jax.numpy.uint32'>, fill_value=4294967295, intrinsic_shape=(), bits=None, packed_bits=None, unpacked_dtype=None, unpacked_intrinsic_shape=None, fill_value_factory=None, validator=None))[source]
Bases:
object- property at
- property batch_shape
- property bytes
Convert entire state tree to flattened byte array.
- check_invariants()
- classmethod default(shape: Tuple[int, ...] = ()) T
- default_dtype = (<class 'jax.numpy.uint32'>,)
- default_shape = ((),)
- property dtype
- flatten()
- from_tuple()
- hash(seed=0)
Main hash function that converts state to uint32 lanes and hashes them.
- hash_with_uint32ed(seed=0)
Main hash function that converts state to uint32 lanes and hashes them. Returns both hash value and its uint32 representation.
- index: FieldDescriptor(dtype=<class 'jax.numpy.uint32'>, fill_value=4294967295, intrinsic_shape=(), bits=None, packed_bits=None, unpacked_dtype=None, unpacked_intrinsic_shape=None, fill_value_factory=None, validator=None)
- is_xtructed = True
- classmethod load(path: str) T
Loads an instance from a .npz file.
- property ndim: int
Return number of batch dimensions for structured instances.
- padding_as_batch(batch_shape: tuple[int, ...])
- classmethod random(shape=(), key=None)
- replace(**kwargs)
- reshape(*new_shape: int | tuple[int, ...]) T
- save(path: str, *, packed: bool = True)
Saves the instance to a .npz file.
- property shape
- str(**kwargs)
- property structured_type: StructuredType
- to_tuple()
- transpose(axes: tuple[int, ...] | None = None) T
- property uint32ed
Convert pytree to uint32 array.
- class xtructure.hashtable.HashTable(seed: int, capacity: int, _capacity: int, bucket_size: int, size: int, table: Xtructurable, bucket_fill_levels: Array | ndarray | bool | number, fingerprints: Array | ndarray | bool | number, max_probes: int)[source]
Bases:
objectBucketed Double Hash Table Implementation
Uses double hashing with buckets to resolve collisions.
- bucket_fill_levels: Array | ndarray | bool | number
- bucket_size: int
- static build(dataclass: Xtructurable, seed: int, capacity: int, bucket_size: int = 8, hash_size_multiplier: int = 2, max_probes: int | None = None) HashTable[source]
Initialize a new hash table backed by JAX-friendly storage.
- capacity: int
- fingerprints: Array | ndarray | bool | number
- from_tuple()
- insert(input: Xtructurable) tuple[HashTable, bool, HashIdx][source]
- lookup(input: Xtructurable) tuple[HashIdx, bool][source]
- lookup_bucket(input: Xtructurable) tuple[BucketIdx, bool, Array | ndarray | bool | number][source]
- lookup_parallel(inputs: Xtructurable, filled: Array | ndarray | bool | number | bool = True) tuple[HashIdx, Array | ndarray | bool | number][source]
- max_probes: int
- parallel_insert(inputs: Xtructurable, filled: Array | ndarray | bool | number | bool = None, unique_key: Array | ndarray | bool | number = None)[source]
- replace(**kwargs)
- seed: int
- size: int
- table: Xtructurable
- to_tuple()