PqIndex class

Product-quantization search index. Requires train(...) before add(...). Stores each vector as m bytes; search uses ADC and ranks in approximate squared-L2 space.

Constructors

PqIndex(int dim, {required int m, int seed = 1234, int niter = 25})

Properties

dim int
final
hashCode int
The hash code for this object.
no setterinherited
isTrained bool
no setter
length int
no setter
liveIds Iterable<Object?>
V50: snapshot of ids in insertion order.
no setter
m int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Object? id, Vector v) → void
Add v under key id. Encodes on-the-fly into the running code buffer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeId(Object? id) bool
Remove the first entry whose id equals id via swap-last. O(N).
Top-k nearest neighbors of query under ADC. The metric arg is accepted for API symmetry but ignored — PQ ranks in approximate squared-L2 always.
toJson() Map<String, Object?>
Serialize the trained codebooks + code table.
toString() String
A string representation of this object.
inherited
train(List<Vector> samples) → void
Fit codebooks on training vectors.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromJson(Map<String, Object?> j) PqIndex
Reconstruct a PqIndex from toJson output.