Class RaBitQuantizer
- All Implemented Interfaces:
Quantizer
This class provides the logic to encode a RealVector into an EncodedRealVector.
The encoding process involves finding an optimal scaling factor, quantizing the vector's components,
and pre-calculating values that facilitate efficient distance estimation in the quantized space.
It is configured with a specific Metric and a number of "extra bits" (numExBits)
which control the precision of the quantization.
Note that this implementation largely follows this paper by Jianyang Gao et al. It also mirrors algorithmic similarity, terms, and variable/method naming-conventions of the C++ implementation that can be found here.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRaBitQuantizer(Metric metric, int numExBits) Constructs a newRaBitQuantizerinstance. -
Method Summary
Modifier and TypeMethodDescriptionencode(RealVector vector) Encodes a givenRealVectorinto its corresponding encoded representation.Creates and returns a newRaBitEstimatorinstance.
-
Constructor Details
-
RaBitQuantizer
Constructs a newRaBitQuantizerinstance.This constructor initializes the quantizer with a specific metric and the number of extra bits to be used in the quantization process.
- Parameters:
metric- theMetricto be used for quantization; must not be null.numExBits- the number of extra bits for quantization.
-
-
Method Details
-
estimator
Creates and returns a newRaBitEstimatorinstance.This method acts as a factory, constructing the estimator based on the
metricandnumExBitsconfiguration of this object. The@Overrideannotation indicates that this is an implementation of a method from a superclass or interface.- Specified by:
estimatorin interfaceQuantizer- Returns:
- a new, non-null instance of
RaBitEstimator
-
encode
Encodes a givenRealVectorinto its corresponding encoded representation.This method overrides the parent's
encodemethod. It delegates the core encoding logic to an internal helper method and returns the finalEncodedRealVector.- Specified by:
encodein interfaceQuantizer- Parameters:
vector- theRealVectorto be encoded; must not be null.- Returns:
- the resulting
EncodedRealVector, guaranteed to be non-null.
-