Record Class Config

java.lang.Object
java.lang.Record
com.apple.foundationdb.async.hnsw.Config
Record Components:
metric - the metric used to determine distances between vectors
numDimensions - the number of dimensions; all vectors must have exactly this many dimensions
useInlining - whether layers above 0 use inlined storage (vectors stored with neighbor links)
m - the target connectivity for each node (named M in the HNSW paper)
mMax - the maximum connectivity for nodes on layers above 0 (M_max in the paper)
mMax0 - the maximum connectivity for nodes on layer 0 (M_max0 in the paper)
efConstruction - the search queue size during insertion (higher = more accurate but slower)
efRepair - the candidate set size during delete repair
extendCandidates - whether to extend the candidate set with neighbors-of-neighbors during insert
keepPrunedConnections - whether to re-add pruned candidates to pad underconnected nodes
sampleVectorStatsProbability - probability of sampling a vector write for statistics computation
maintainStatsProbability - probability of aggregating sampled vectors during insert
statsThreshold - number of sampled vectors that triggers centroid computation
useRaBitQ - whether to use RaBitQ quantization
raBitQNumExBits - number of extra bits per dimension for RaBitQ encoding
maxNumConcurrentNodeFetches - maximum concurrent node fetches during search and modification
maxNumConcurrentNeighborhoodFetches - maximum concurrent neighborhood fetches during pruning
maxNumConcurrentDeleteFromLayer - maximum concurrent delete operations per layer
All Implemented Interfaces:
VectorEncodingConfig

public record Config(@Nonnull Metric metric, int numDimensions, boolean useInlining, int m, int mMax, int mMax0, int efConstruction, int efRepair, boolean extendCandidates, boolean keepPrunedConnections, double sampleVectorStatsProbability, double maintainStatsProbability, int statsThreshold, boolean useRaBitQ, int raBitQNumExBits, int maxNumConcurrentNodeFetches, int maxNumConcurrentNeighborhoodFetches, int maxNumConcurrentDeleteFromLayer) extends Record implements VectorEncodingConfig
Configuration settings for an HNSW.
  • Field Details

    • DEFAULT_METRIC

      @Nonnull public static final Metric DEFAULT_METRIC
    • DEFAULT_USE_INLINING

      public static final boolean DEFAULT_USE_INLINING
      See Also:
    • DEFAULT_M

      public static final int DEFAULT_M
      See Also:
    • DEFAULT_M_MAX_0

      public static final int DEFAULT_M_MAX_0
      See Also:
    • DEFAULT_M_MAX

      public static final int DEFAULT_M_MAX
      See Also:
    • DEFAULT_EF_CONSTRUCTION

      public static final int DEFAULT_EF_CONSTRUCTION
      See Also:
    • DEFAULT_EF_REPAIR

      public static final int DEFAULT_EF_REPAIR
      See Also:
    • DEFAULT_EXTEND_CANDIDATES

      public static final boolean DEFAULT_EXTEND_CANDIDATES
      See Also:
    • DEFAULT_KEEP_PRUNED_CONNECTIONS

      public static final boolean DEFAULT_KEEP_PRUNED_CONNECTIONS
      See Also:
    • DEFAULT_SAMPLE_VECTOR_STATS_PROBABILITY

      public static final double DEFAULT_SAMPLE_VECTOR_STATS_PROBABILITY
      See Also:
    • DEFAULT_MAINTAIN_STATS_PROBABILITY

      public static final double DEFAULT_MAINTAIN_STATS_PROBABILITY
      See Also:
    • DEFAULT_STATS_THRESHOLD

      public static final int DEFAULT_STATS_THRESHOLD
      See Also:
    • DEFAULT_USE_RABITQ

      public static final boolean DEFAULT_USE_RABITQ
      See Also:
    • DEFAULT_RABITQ_NUM_EX_BITS

      public static final int DEFAULT_RABITQ_NUM_EX_BITS
      See Also:
    • DEFAULT_MAX_NUM_CONCURRENT_NODE_FETCHES

      public static final int DEFAULT_MAX_NUM_CONCURRENT_NODE_FETCHES
      See Also:
    • DEFAULT_MAX_NUM_CONCURRENT_NEIGHBOR_FETCHES

      public static final int DEFAULT_MAX_NUM_CONCURRENT_NEIGHBOR_FETCHES
      See Also:
    • DEFAULT_MAX_NUM_CONCURRENT_DELETE_FROM_LAYER

      public static final int DEFAULT_MAX_NUM_CONCURRENT_DELETE_FROM_LAYER
      See Also:
  • Constructor Details

    • Config

      public Config(@Nonnull Metric metric, int numDimensions, boolean useInlining, int m, int mMax, int mMax0, int efConstruction, int efRepair, boolean extendCandidates, boolean keepPrunedConnections, double sampleVectorStatsProbability, double maintainStatsProbability, int statsThreshold, boolean useRaBitQ, int raBitQNumExBits, int maxNumConcurrentNodeFetches, int maxNumConcurrentNeighborhoodFetches, int maxNumConcurrentDeleteFromLayer)
      Creates an instance of a Config record class.
      Parameters:
      metric - the value for the metric record component
      numDimensions - the value for the numDimensions record component
      useInlining - the value for the useInlining record component
      m - the value for the m record component
      mMax - the value for the mMax record component
      mMax0 - the value for the mMax0 record component
      efConstruction - the value for the efConstruction record component
      efRepair - the value for the efRepair record component
      extendCandidates - the value for the extendCandidates record component
      keepPrunedConnections - the value for the keepPrunedConnections record component
      sampleVectorStatsProbability - the value for the sampleVectorStatsProbability record component
      maintainStatsProbability - the value for the maintainStatsProbability record component
      statsThreshold - the value for the statsThreshold record component
      useRaBitQ - the value for the useRaBitQ record component
      raBitQNumExBits - the value for the raBitQNumExBits record component
      maxNumConcurrentNodeFetches - the value for the maxNumConcurrentNodeFetches record component
      maxNumConcurrentNeighborhoodFetches - the value for the maxNumConcurrentNeighborhoodFetches record component
      maxNumConcurrentDeleteFromLayer - the value for the maxNumConcurrentDeleteFromLayer record component
  • Method Details

    • toBuilder

      @Nonnull public Config.ConfigBuilder toBuilder()
    • toString

      @Nonnull public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • metric

      @Nonnull public Metric metric()
      Returns the value of the metric record component.
      Specified by:
      metric in interface VectorEncodingConfig
      Returns:
      the value of the metric record component
    • numDimensions

      public int numDimensions()
      Returns the value of the numDimensions record component.
      Specified by:
      numDimensions in interface VectorEncodingConfig
      Returns:
      the value of the numDimensions record component
    • useInlining

      public boolean useInlining()
      Returns the value of the useInlining record component.
      Returns:
      the value of the useInlining record component
    • m

      public int m()
      Returns the value of the m record component.
      Returns:
      the value of the m record component
    • mMax

      public int mMax()
      Returns the value of the mMax record component.
      Returns:
      the value of the mMax record component
    • mMax0

      public int mMax0()
      Returns the value of the mMax0 record component.
      Returns:
      the value of the mMax0 record component
    • efConstruction

      public int efConstruction()
      Returns the value of the efConstruction record component.
      Returns:
      the value of the efConstruction record component
    • efRepair

      public int efRepair()
      Returns the value of the efRepair record component.
      Returns:
      the value of the efRepair record component
    • extendCandidates

      public boolean extendCandidates()
      Returns the value of the extendCandidates record component.
      Returns:
      the value of the extendCandidates record component
    • keepPrunedConnections

      public boolean keepPrunedConnections()
      Returns the value of the keepPrunedConnections record component.
      Returns:
      the value of the keepPrunedConnections record component
    • sampleVectorStatsProbability

      public double sampleVectorStatsProbability()
      Returns the value of the sampleVectorStatsProbability record component.
      Returns:
      the value of the sampleVectorStatsProbability record component
    • maintainStatsProbability

      public double maintainStatsProbability()
      Returns the value of the maintainStatsProbability record component.
      Returns:
      the value of the maintainStatsProbability record component
    • statsThreshold

      public int statsThreshold()
      Returns the value of the statsThreshold record component.
      Returns:
      the value of the statsThreshold record component
    • useRaBitQ

      public boolean useRaBitQ()
      Returns the value of the useRaBitQ record component.
      Specified by:
      useRaBitQ in interface VectorEncodingConfig
      Returns:
      the value of the useRaBitQ record component
    • raBitQNumExBits

      public int raBitQNumExBits()
      Returns the value of the raBitQNumExBits record component.
      Specified by:
      raBitQNumExBits in interface VectorEncodingConfig
      Returns:
      the value of the raBitQNumExBits record component
    • maxNumConcurrentNodeFetches

      public int maxNumConcurrentNodeFetches()
      Returns the value of the maxNumConcurrentNodeFetches record component.
      Returns:
      the value of the maxNumConcurrentNodeFetches record component
    • maxNumConcurrentNeighborhoodFetches

      public int maxNumConcurrentNeighborhoodFetches()
      Returns the value of the maxNumConcurrentNeighborhoodFetches record component.
      Returns:
      the value of the maxNumConcurrentNeighborhoodFetches record component
    • maxNumConcurrentDeleteFromLayer

      public int maxNumConcurrentDeleteFromLayer()
      Returns the value of the maxNumConcurrentDeleteFromLayer record component.
      Returns:
      the value of the maxNumConcurrentDeleteFromLayer record component