Class OnDiskGraphIndexWriter
java.lang.Object
io.github.jbellis.jvector.graph.disk.OnDiskGraphIndexWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
Write a graph index to disk, for later loading as an OnDiskGraphIndex.
Implements `getFeatureSource` to allow incremental construction of a larger-than-memory graph (using the writer as the source of INLINE_VECTORS or LVQ).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for OnDiskGraphIndexWriter, with optional features.static class
static interface
-
Method Summary
Modifier and TypeMethodDescriptionlong
checksum()
CRC32 checksum of bytes written since the starting offsetvoid
close()
int
sequentialRenumbering
(GraphIndex graph) void
write
(Map<FeatureId, IntFunction<Feature.State>> featureStateSuppliers) Write the complete index to the given output.void
writeInline
(int ordinal, Map<FeatureId, Feature.State> stateMap) Write the inline features of the given ordinal to the output at the correct offset.
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getOutput
-
writeInline
Write the inline features of the given ordinal to the output at the correct offset. Nothing else is written (no headers, no edges).- Throws:
IOException
-
getMaxOrdinal
public int getMaxOrdinal() -
getFeatureSource
-
write
public void write(Map<FeatureId, IntFunction<Feature.State>> featureStateSuppliers) throws IOExceptionWrite the complete index to the given output. Features that do not have a supplier are assumed to have already been written by calls to writeInline. The supplier takes node ordinals and returns FeatureState suitable for Feature.writeInline.- Throws:
IOException
-
sequentialRenumbering
- 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. "Holes" left by deleted nodes are filled in by shifting down the new ordinals.
-
checksum
CRC32 checksum of bytes written since the starting offset- Throws:
IOException
-