Package io.github.jbellis.jvector.disk
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
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.github.jbellis.jvector.graph.GraphIndex
GraphIndex.View<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getNodes()Get all node ordinals included in the graph.getSequentialRenumbering(GraphIndex<T> graph) getView()return a Graph that can be safely queried concurrentlyintlongintsize()Returns the number of nodes in the graphstatic <T> voidwrite(GraphIndex<T> graph, RandomAccessVectorValues<T> vectors, DataOutput out) static <T> voidwrite(GraphIndex<T> graph, RandomAccessVectorValues<T> vectors, Map<Integer, Integer> oldToNewOrdinals, DataOutput out) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.jbellis.jvector.graph.GraphIndex
containsNode, getIdUpperBound
-
Constructor Details
-
OnDiskGraphIndex
-
-
Method Details
-
getSequentialRenumbering
- 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:GraphIndexReturns the number of nodes in the graph- Specified by:
sizein interfaceGraphIndex<T>
-
maxDegree
public int maxDegree()- Specified by:
maxDegreein interfaceGraphIndex<T>- Returns:
- the maximum number of edges per node
-
getView
return a Graph that can be safely queried concurrently- Specified by:
getViewin interfaceGraphIndex<T>
-
getNodes
Description copied from interface:GraphIndexGet all node ordinals included in the graph. The nodes are NOT guaranteed to be presented in any particular order.- Specified by:
getNodesin interfaceGraphIndex<T>- Returns:
- an iterator over nodes where
nextIntreturns the next node.
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceAccountable
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGraphIndex<T>- Throws:
IOException
-
write
public static <T> void write(GraphIndex<T> graph, RandomAccessVectorValues<T> vectors, DataOutput out) throws IOException - Parameters:
graph- the graph to writevectors- the vectors associated with each nodeout- 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 writevectors- the vectors associated with each nodeoldToNewOrdinals- 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
-