Record Class SearchConfig
java.lang.Object
java.lang.Record
com.apple.foundationdb.async.guardiann.SearchConfig
- Record Components:
candidatePoolFactor- how large the in-flight candidate pool should be relative to the requestedk, expressed as a multiple (e.g.1.15keeps a pool 15% larger thank); the absolute pool size for a given search iscandidatePoolSize(int). Beingk-relative rather than absolute, it can be tuned once and reused across searches asking for differentk. In the prunedSearch.kNearestNeighborsSearch(com.apple.foundationdb.ReadTransaction, int, com.apple.foundationdb.async.guardiann.SearchConfig, boolean, com.apple.foundationdb.linear.RealVector)the pool is the size of theDistinctTopKcandidate pool; in the streamingSearch.searchOrderedByDistance(com.apple.foundationdb.ReadTransaction, int, com.apple.foundationdb.async.guardiann.SearchConfig, com.apple.foundationdb.linear.RealVector, double, double, com.apple.foundationdb.tuple.Tuple)it is the reorder-window size of the almost-sorted iterator. Larger values improve recall/ordering at the cost of latency. Must be>= 1.0so the pool is never smaller thank. (This replaces the old, absolutecandidatePoolSize— itself the rename of the misleadingly namedefSearch, unrelated to HNSW'sefSearch.)searchMaxClusters- the maximum number of cluster centroids to probe around the querysearchMinClustersBeforePruning- the number of nearest clusters always retained before distance-ratio pruning is allowed to drop any (pruned search only; ignored by the streaming search)searchDistanceRatioCutoff- clusters whose centroid distance exceeds this multiple of the nearest centroid's distance are pruned, oncesearchMinClustersBeforePruningclusters are retained (pruned search only; ignored by the streaming search)centroidEfRingSearch- the ring-search exploration factor for the centroid HNSW walk that selects candidate clusters (passed through toHNSW.orderByDistance(com.apple.foundationdb.ReadTransaction, int, int, boolean, com.apple.foundationdb.linear.RealVector, double, com.apple.foundationdb.tuple.Tuple, boolean))centroidEfOutwardSearch- the outward-search exploration factor (candidate-queue size) for that same centroid HNSW walksearchConcurrency- the executor parallelism for the fan-out metadata/reference reads a search issues
public record SearchConfig(double candidatePoolFactor, int searchMaxClusters, int searchMinClustersBeforePruning, double searchDistanceRatioCutoff, int centroidEfRingSearch, int centroidEfOutwardSearch, int searchConcurrency)
extends Record
The performance/recall tuning knobs for a single Guardiann search. These are the parameters that change how hard the
search works — how many candidates it buffers, how many clusters it probes, how aggressively it prunes — without
changing what a correct answer is. The semantic inputs (
k, the query vector, includeVectors,
and the streaming pagination cursor) stay direct arguments of the search methods; everything that only trades latency
against recall lives here so it can travel as one value and grow without widening every signature.
There is deliberately no built-in "default" instance: good values depend on the dataset, its size, the index
topology, and the recall target, so picking them is the caller's (or the test harness's) responsibility. The
DEFAULT_* constants exist only as the SearchConfig.SearchConfigBuilder's per-field fallbacks, so a caller can set
just the knobs it cares about and leave the rest at a reasonable starting point.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final intstatic final intstatic final intstatic final doublestatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionSearchConfig(double candidatePoolFactor, int searchMaxClusters, int searchMinClustersBeforePruning, double searchDistanceRatioCutoff, int centroidEfRingSearch, int centroidEfOutwardSearch, int searchConcurrency) Creates an instance of aSearchConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thecandidatePoolFactorrecord component.intcandidatePoolSize(int k) Resolves the absolute candidate-pool size for a search asking forkresults by applyingcandidatePoolFactor().intReturns the value of thecentroidEfOutwardSearchrecord component.intReturns the value of thecentroidEfRingSearchrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thesearchConcurrencyrecord component.doubleReturns the value of thesearchDistanceRatioCutoffrecord component.intReturns the value of thesearchMaxClustersrecord component.intReturns the value of thesearchMinClustersBeforePruningrecord component.toString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_CANDIDATE_POOL_FACTOR
public static final double DEFAULT_CANDIDATE_POOL_FACTOR- See Also:
-
DEFAULT_SEARCH_MAX_CLUSTERS
public static final int DEFAULT_SEARCH_MAX_CLUSTERS- See Also:
-
DEFAULT_SEARCH_MIN_CLUSTERS_BEFORE_PRUNING
public static final int DEFAULT_SEARCH_MIN_CLUSTERS_BEFORE_PRUNING- See Also:
-
DEFAULT_SEARCH_DISTANCE_RATIO_CUTOFF
public static final double DEFAULT_SEARCH_DISTANCE_RATIO_CUTOFF- See Also:
-
DEFAULT_CENTROID_EF_RING_SEARCH
public static final int DEFAULT_CENTROID_EF_RING_SEARCH- See Also:
-
DEFAULT_CENTROID_EF_OUTWARD_SEARCH
public static final int DEFAULT_CENTROID_EF_OUTWARD_SEARCH- See Also:
-
DEFAULT_SEARCH_CONCURRENCY
public static final int DEFAULT_SEARCH_CONCURRENCY- See Also:
-
-
Constructor Details
-
SearchConfig
public SearchConfig(double candidatePoolFactor, int searchMaxClusters, int searchMinClustersBeforePruning, double searchDistanceRatioCutoff, int centroidEfRingSearch, int centroidEfOutwardSearch, int searchConcurrency) Creates an instance of aSearchConfigrecord class.- Parameters:
candidatePoolFactor- the value for thecandidatePoolFactorrecord componentsearchMaxClusters- the value for thesearchMaxClustersrecord componentsearchMinClustersBeforePruning- the value for thesearchMinClustersBeforePruningrecord componentsearchDistanceRatioCutoff- the value for thesearchDistanceRatioCutoffrecord componentcentroidEfRingSearch- the value for thecentroidEfRingSearchrecord componentcentroidEfOutwardSearch- the value for thecentroidEfOutwardSearchrecord componentsearchConcurrency- the value for thesearchConcurrencyrecord component
-
-
Method Details
-
candidatePoolSize
public int candidatePoolSize(int k) Resolves the absolute candidate-pool size for a search asking forkresults by applyingcandidatePoolFactor(). The result is rounded up and clamped to at leastk, so the pool is never smaller than the requested top-k even for a factor of exactly1.0or tinyk.- Parameters:
k- the number of results the search will ultimately return- Returns:
- the number of candidates to keep in flight before trimming to
k
-
toBuilder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
candidatePoolFactor
public double candidatePoolFactor()Returns the value of thecandidatePoolFactorrecord component.- Returns:
- the value of the
candidatePoolFactorrecord component
-
searchMaxClusters
public int searchMaxClusters()Returns the value of thesearchMaxClustersrecord component.- Returns:
- the value of the
searchMaxClustersrecord component
-
searchMinClustersBeforePruning
public int searchMinClustersBeforePruning()Returns the value of thesearchMinClustersBeforePruningrecord component.- Returns:
- the value of the
searchMinClustersBeforePruningrecord component
-
searchDistanceRatioCutoff
public double searchDistanceRatioCutoff()Returns the value of thesearchDistanceRatioCutoffrecord component.- Returns:
- the value of the
searchDistanceRatioCutoffrecord component
-
centroidEfRingSearch
public int centroidEfRingSearch()Returns the value of thecentroidEfRingSearchrecord component.- Returns:
- the value of the
centroidEfRingSearchrecord component
-
centroidEfOutwardSearch
public int centroidEfOutwardSearch()Returns the value of thecentroidEfOutwardSearchrecord component.- Returns:
- the value of the
centroidEfOutwardSearchrecord component
-
searchConcurrency
public int searchConcurrency()Returns the value of thesearchConcurrencyrecord component.- Returns:
- the value of the
searchConcurrencyrecord component
-