GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE] Provide a possibility to store and load an empty graph by reta · Pull Request #685 · datastax/jvector

Conversation

@reta

@reta reta commented Jun 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Provide a possibility to store and load an empty graph, see please #684 for motivation and background.

Closes #684

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@reta
reta force-pushed the issue-684 branch 3 times, most recently from c9c2ef2 to a2b357f Compare June 19, 2026 17:58
@reta
[FEATURE] Provide a possibility to store and load an empty graph
4a21b41
Signed-off-by: Andriy Redko <[email protected]>
@reta
reta force-pushed the issue-684 branch from a2b357f to 4a21b41 Compare June 19, 2026 18:41
@reta
reta marked this pull request as ready for review June 19, 2026 18:43
@reta
reta requested review from MarkWolters, ashkrisk, jshook and tlwillke as code owners June 19, 2026 18:43
ashkrisk
ashkrisk reviewed Jun 21, 2026
View reviewed changes

@ashkrisk ashkrisk left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reta thanks for this PR. I've left a few comments. Additionally, I tried running a test by saving and loading an empty heap graph to an OnDiskGraphIndex, but this failed an assertion while loading the graph. The test in this PR only covers OnHeapGraphIndex::save and OnHeapGraphIndex::load.

I'll try and take a look at this later. In the meantime, if you manage to figure out the issue, please do update the PR.

Failure details

The error:

java.lang.AssertionError: Node ID -1419795886 out of bounds for layer 1

The sample program is below, please run with assertions enabled.

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;

import io.github.jbellis.jvector.disk.ReaderSupplierFactory;

import io.github.jbellis.jvector.graph.GraphIndexBuilder;
import io.github.jbellis.jvector.graph.ListRandomAccessVectorValues;
import io.github.jbellis.jvector.graph.disk.GraphIndexWriter;
import io.github.jbellis.jvector.graph.disk.GraphIndexWriterTypes;
import io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex;
import io.github.jbellis.jvector.graph.disk.feature.FeatureId;
import io.github.jbellis.jvector.graph.disk.feature.InlineVectors;
import io.github.jbellis.jvector.graph.similarity.BuildScoreProvider;
import io.github.jbellis.jvector.vector.VectorSimilarityFunction;

public class Test {
    public static void main(String[] forwardArgs) throws IOException {
        
        var dim = 1024;
        var vsf = VectorSimilarityFunction.DOT_PRODUCT;

        var M = 32;
        var ef = 100;
        var nOv = 1.2f;
        var alpha = 1.2f;
        var hier = true;

        var ravv = new ListRandomAccessVectorValues(List.of(), dim);
        var bsp = BuildScoreProvider.randomAccessScoreProvider(ravv, vsf);
        var graphPath = Path.of("./local/tmp.jvgraph");

        try (
            var builder = new GraphIndexBuilder(bsp, dim, M, ef, nOv, alpha, hier);
            var graph = builder.build(ravv);
            var writer = GraphIndexWriter.getBuilderFor(GraphIndexWriterTypes.RANDOM_ACCESS_PARALLEL, graph, graphPath)
                .with(new InlineVectors(dim))
                .build();
        ) {
            writer.write(Map.of(FeatureId.INLINE_VECTORS, i -> new InlineVectors.State(ravv.getVector(i))));
            System.out.println("OHG max level = " + graph.getMaxLevel());
        }

        try (
            var readerSupplier = ReaderSupplierFactory.open(graphPath);
            var graph = OnDiskGraphIndex.load(readerSupplier);
        ) {
            var count = 0;
            var niter = graph.getNodes(0);
            while (niter.hasNext()) {
                count++;
                System.out.println(">>> " + niter.next());
            }
            System.out.println(String.format("Counted %d nodes", count));
            graph.getDegree(0);
        }
    }
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

reta reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Comment thread jvector-tests/src/test/java/io/github/jbellis/jvector/graph/GraphIndexBuilderTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jvector-base/src/main/java/io/github/jbellis/jvector/graph/ImmutableGraphIndex.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jvector-base/src/main/java/io/github/jbellis/jvector/graph/disk/OnDiskGraphIndex.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

reta added 2 commits June 22, 2026 08:24
@reta
Address code review comments
b742ee5
Signed-off-by: Andriy Redko <[email protected]>
@reta
Added OnDiskGraphIndex test for empty graphs
4bdb31a
Signed-off-by: Andriy Redko <[email protected]>
@reta
reta force-pushed the issue-684 branch from b5f82d2 to 62992af Compare June 22, 2026 16:06
@reta
Address code review comments
f808119
Signed-off-by: Andriy Redko <[email protected]>
@reta
reta force-pushed the issue-684 branch from 62992af to f808119 Compare June 22, 2026 18:58
@reta

reta commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

I'll try and take a look at this later. In the meantime, if you manage to figure out the issue, please do update the PR.

Thanks @ashkrisk , sorry forgot to update on this one,

Jun 23, 2026 8:53:10 A.M. io.github.jbellis.jvector.vector.VectorizationProvider lookup
WARNING: Java vector incubator module is not readable. For optimal vector performance, pass '--add-modules jdk.incubator.vector' to enable Vector API.
Jun 23, 2026 8:53:16 A.M. io.github.jbellis.jvector.util.PhysicalCoreExecutor resolvePhysicalCoreCount
INFO: PhysicalCoreExecutor: using 10 worker threads, determined by OS topology probe on "Mac OS X" (detected 10 physical cores, clamped to availableProcessors=10).
Jun 23, 2026 8:53:16 A.M. io.github.jbellis.jvector.util.PhysicalCoreExecutor resolvePhysicalCoreCount
WARNING: PhysicalCoreExecutor: previous auto-sized worker threads on this node would have been 5, but aligning to cores now sets them to 10. Set the jvector.physical_core_count system property to override.
08:53:16.350 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing common header at position 0
08:53:16.351 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing 1 layers
08:53:16.351 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Common header finished writing at position 288
08:53:16.361 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing common header at position 296
08:53:16.361 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing 1 layers
08:53:16.361 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Common header finished writing at position 584
08:53:16.361 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing common header at position 0
08:53:16.361 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Writing 1 layers
08:53:16.362 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Common header finished writing at position 288
OHG max level = 0
....

08:53:16.386 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Loading OnDiskGraphIndex from offset=0
08:53:16.386 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Loading common header at position 0
08:53:16.388 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - 1 layers
08:53:16.388 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Common header finished reading at position 288
08:53:16.388 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Header loaded: version=6, dimension=1024, entryNode=-1, layerInfoCount=1
08:53:16.388 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Position after reading header=296
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Version 5+ onwards uses a footer instead of header for metadata. Loading from footer
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Loading OnDiskGraphIndex footer from offset=600
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Loading header offset=592
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Loading OnDiskGraphIndex header from offset=296
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Loading common header at position 296
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - 1 layers
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.CommonHeader - Common header finished reading at position 584
08:53:16.389 [main] DEBUG io.github.jbellis.jvector.graph.disk.OnDiskGraphIndex - Header loaded: version=6, dimension=1024, entryNode=-1, layerInfoCount=1, Position after reading header=592
Counted 0 nodes

I run it against latest changes with assertions enabled - no issues, please let me know if I am missing something, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tlwillke tlwillke assigned reta and ashkrisk Jun 24, 2026
@tlwillke tlwillke added the enhancement New feature or request label Jun 24, 2026
ashkrisk
ashkrisk reviewed Jun 25, 2026
View reviewed changes

@ashkrisk ashkrisk left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reta the new test for for the empty OnDiskGraphIndex looks good. I think the earlier failure I was seeing had to do with improper file cleanup on my system, I sorted that out and it runs fine now.

My remaining comments are mostly nitpicks. There are a lot of lines consisting of multiple spaces followed by a newline (Bob has a tendency to preserve indentation for empty lines), it would be better if you can remove those as well.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread jvector-tests/src/test/java/io/github/jbellis/jvector/TestUtil.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jvector-tests/src/test/java/io/github/jbellis/jvector/TestUtil.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jvector-tests/src/test/java/io/github/jbellis/jvector/TestUtil.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

reta added 2 commits June 25, 2026 09:52
@reta
Address code review comments
fb351c3
Signed-off-by: Andriy Redko <[email protected]>
@reta
Address code review comments
11b6019
Signed-off-by: Andriy Redko <[email protected]>
@reta

reta commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

My remaining comments are mostly nitpicks. There are a lot of lines consisting of multiple spaces followed by a newline (Bob has a tendency to preserve indentation for empty lines), it would be better if you can remove those as well.

Thanks @ashkrisk , really appreciate it, I think we should be all set now

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashkrisk

ashkrisk commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@reta we just merged #688 which fixes the CI issues for PRs from forks. Can you please rebase on the latest main?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@reta
Merge remote-tracking branch 'origin/main' into issue-684
8ddbb18
@reta

reta commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@reta we just merged #688 which fixes the CI issues for PRs from forks. Can you please rebase on the latest main?

Done, thanks a lot @ashkrisk !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@reta

reta commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@ashkrisk thanks again for the review, anything holding this change off? we really need it to fix a bug on opensearch-jvector and further on OpenRAG part, thank you

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jshook
jshook approved these changes Jul 7, 2026
View reviewed changes

@jshook jshook left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw no obvious issues with this, and tests look sound

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

reta reacted with heart emoji
All reactions
  • ❤️ 1 reaction
MarkWolters
MarkWolters approved these changes Jul 8, 2026
View reviewed changes

@MarkWolters MarkWolters left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates the graph writing process to write a -1 as entry node ordinal as a flag that the graph is empty. If empty graphs are written and then re-loaded by a previous version of jvector, eg for a rollback, the graph will be loaded as a valid graph, but the header correctly indicates size of 0. Searches against the graph using the OnDiskGraphIndex View do not cause failures. This seems like a reasonable approach.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

reta and akash-shankaran reacted with heart emoji
All reactions
  • ❤️ 2 reactions
ashkrisk
ashkrisk approved these changes Jul 9, 2026
View reviewed changes
@ashkrisk
ashkrisk merged commit 838d74a into datastax:main Jul 9, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jshook jshook jshook approved these changes
@MarkWolters MarkWolters MarkWolters approved these changes
@ashkrisk ashkrisk ashkrisk approved these changes
@tlwillke tlwillke Awaiting requested review from tlwillke tlwillke is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@reta reta

@ashkrisk ashkrisk

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE] Provide a possibility to store and load an empty graph

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@reta @ashkrisk @jshook @MarkWolters @tlwillke
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.