Class HnswGraph

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  HnswGraph.NodesIterator
      Iterator over the graph nodes on a certain level, Iterator also provides the size – the total number of nodes to be iterated over.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static HnswGraph EMPTY
      Empty graph value
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected HnswGraph()
      Sole constructor
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract int entryNode()
      Returns graph's entry point on the top level *
      abstract HnswGraph.NodesIterator getNodesOnLevel​(int level)
      Get all nodes on a given level as node 0th ordinals
      abstract int nextNeighbor()
      Iterates over the neighbor list.
      abstract int numLevels()
      Returns the number of levels of the graph
      abstract void seek​(int level, int target)
      Move the pointer to exactly the given level's target.
      abstract int size()
      Returns the number of nodes in the graph
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY

        public static HnswGraph EMPTY
        Empty graph value
    • Constructor Detail

      • HnswGraph

        protected HnswGraph()
        Sole constructor
    • Method Detail

      • seek

        public abstract void seek​(int level,
                                  int target)
                           throws java.io.IOException
        Move the pointer to exactly the given level's target. After this method returns, call nextNeighbor() to return successive (ordered) connected node ordinals.
        Parameters:
        level - level of the graph
        target - ordinal of a node in the graph, must be ≥ 0 and < VectorValues.size().
        Throws:
        java.io.IOException
      • size

        public abstract int size()
        Returns the number of nodes in the graph
      • nextNeighbor

        public abstract int nextNeighbor()
                                  throws java.io.IOException
        Iterates over the neighbor list. It is illegal to call this method after it returns NO_MORE_DOCS without calling seek(int, int), which resets the iterator.
        Returns:
        a node ordinal in the graph, or NO_MORE_DOCS if the iteration is complete.
        Throws:
        java.io.IOException
      • numLevels

        public abstract int numLevels()
                               throws java.io.IOException
        Returns the number of levels of the graph
        Throws:
        java.io.IOException
      • entryNode

        public abstract int entryNode()
                               throws java.io.IOException
        Returns graph's entry point on the top level *
        Throws:
        java.io.IOException
      • getNodesOnLevel

        public abstract HnswGraph.NodesIterator getNodesOnLevel​(int level)
                                                         throws java.io.IOException
        Get all nodes on a given level as node 0th ordinals
        Parameters:
        level - level for which to get all nodes
        Returns:
        an iterator over nodes where nextInt returns a next node on the level
        Throws:
        java.io.IOException