Package com.apple.foundationdb.rabitq
Class RaBitDistanceEstimator
java.lang.Object
com.apple.foundationdb.rabitq.RaBitDistanceEstimator
- All Implemented Interfaces:
DistanceEstimator
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubledistance(RealVector vector1, RealVector vector2) Calculates the distance between two vectors that have already been transformed into the estimator's coordinate system.estimateDistanceAndErrorBound(RealVector query, EncodedRealVector encodedVector) Returns the underlyingMetricthis estimator computes.intbooleanisOptimized(RealVector vector1, RealVector vector2) Returns whether this estimator can compute the distance betweenvector1andvector2on a metric-specific fast path that bypasses the raw metric.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.apple.foundationdb.linear.DistanceEstimator
distance, isOptimized
-
Constructor Details
-
RaBitDistanceEstimator
-
-
Method Details
-
getMetric
Description copied from interface:DistanceEstimatorReturns the underlyingMetricthis estimator computes.- Specified by:
getMetricin interfaceDistanceEstimator
-
isOptimized
Description copied from interface:DistanceEstimatorReturns whether this estimator can compute the distance betweenvector1andvector2on a metric-specific fast path that bypasses the raw metric. For example, a quantization-aware estimator may reporttruewhen at least one of the vectors is in the encoded form it knows how to consume directly.Default
ofMetric-built estimators have no fast path and always returnfalse. Callers can use this hint to skip work that is only worthwhile for the generic path (e.g. avoiding decode of an encoded vector if both will go through the estimator's fast path anyway).- Specified by:
isOptimizedin interfaceDistanceEstimator- Parameters:
vector1- the first vectorvector2- the second vector- Returns:
trueiff this estimator has a metric-specific fast path for the given pair
-
getNumExBits
public int getNumExBits() -
distance
Description copied from interface:DistanceEstimatorCalculates the distance between two vectors that have already been transformed into the estimator's coordinate system.Both arguments must already have been rotated/translated as expected by the estimator before calling this method — implementations do not apply any preprocessing. Implementations may reject distance values that are not finite (depending on the metric and on whether the inputs are zero vectors, etc.) by throwing an
IllegalArgumentException.- Specified by:
distancein interfaceDistanceEstimator- Parameters:
vector1- the first pre-rotated and translated vectorvector2- the second pre-rotated and translated vector- Returns:
- a non-negative
doublerepresenting the distance between the two vectors
-
estimateDistanceAndErrorBound
@Nonnull public RaBitDistanceEstimator.Result estimateDistanceAndErrorBound(@Nonnull RealVector query, @Nonnull EncodedRealVector encodedVector)
-