Class OnDiskGraphIndex<T>

java.lang.Object
io.github.jbellis.jvector.disk.OnDiskGraphIndex<T>
All Implemented Interfaces:
GraphIndex<T>, Accountable, AutoCloseable

public class OnDiskGraphIndex<T> extends Object implements GraphIndex<T>, AutoCloseable, Accountable
  • Constructor Details

    • OnDiskGraphIndex

      public OnDiskGraphIndex(ReaderSupplier readerSupplier, long offset)
  • Method Details

    • getSequentialRenumbering

      public static <T> Map<Integer,Integer> getSequentialRenumbering(GraphIndex<T> graph)
      Returns:
      a Map of old to new graph ordinals where the new ordinals are sequential starting at 0, while preserving the original relative ordering in `graph`. That is, for all node ids i and j, if i < j in `graph` then map[i] < map[j] in the returned map.
    • size

      public int size()
      Description copied from interface: GraphIndex
      Returns the number of nodes in the graph
      Specified by:
      size in interface GraphIndex<T>
    • maxDegree

      public int maxDegree()
      Specified by:
      maxDegree in interface GraphIndex<T>
      Returns:
      the maximum number of edges per node
    • getView

      public OnDiskGraphIndex<T>.OnDiskView getView()
      return a Graph that can be safely queried concurrently
      Specified by:
      getView in interface GraphIndex<T>
    • getNodes

      public NodesIterator getNodes()
      Description copied from interface: GraphIndex
      Get all node ordinals included in the graph. The nodes are NOT guaranteed to be presented in any particular order.
      Specified by:
      getNodes in interface GraphIndex<T>
      Returns:
      an iterator over nodes where nextInt returns the next node.
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface Accountable
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface GraphIndex<T>
      Throws:
      IOException
    • write

      public static <T> void write(GraphIndex<T> graph, RandomAccessVectorValues<T> vectors, DataOutput out) throws IOException
      Parameters:
      graph - the graph to write
      vectors - the vectors associated with each node
      out - the output to write to If any nodes have been deleted, you must use the overload specifying `oldToNewOrdinals` instead.
      Throws:
      IOException
    • write

      public static <T> void write(GraphIndex<T> graph, RandomAccessVectorValues<T> vectors, Map<Integer,Integer> oldToNewOrdinals, DataOutput out) throws IOException
      Parameters:
      graph - the graph to write
      vectors - the vectors associated with each node
      oldToNewOrdinals - A map from old to new ordinals. If ordinal numbering does not matter, you can use `getSequentialRenumbering`, which will "fill in" holes left by any deleted nodes.
      out - the output to write to
      Throws:
      IOException