Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Neo4jGraph key indices inconsistent w.r.t. element removal #274

Closed
joshsh opened this Issue · 4 comments

3 participants

@joshsh
Owner

The remaining GraphSail-on-Neo4jGraph issues (apart from those which are fixed with the setCheckElementsInTransaction(true) hack) are related to the inconsistent behavior of Neo4jGraph's key indices. One immediate problem is that if you remove a vertex or edge, and then look up the vertex or edge with an index-based getVertices(String, Object) or getEdges(String, Object), you will get back a reference to a non-existent element which will then fail with a transaction error if you try to use it (e.g. by getting a property value).

The following test case has been added (but commented out) at the bottom of KeyIndexableGraphTestSuite. It passes for DexGraph and TinkerGraph, but fails for Neo4jGraph:

        KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();

        graph.createKeyIndex("foo", Vertex.class);

        Vertex v1 = graph.addVertex(null);
        v1.setProperty("foo", 42);
        vertexCount(graph, 1);

        graph.removeVertex(v1);
        vertexCount(graph, 0);
        assertEquals(0, count(graph.getVertices("foo", 42)));

        graph.shutdown();
@okram
Owner

Note the Neo4jGraph.checkElementInTransaction(boolean). That's how you force this to work.

@okram okram closed this
@joshsh joshsh reopened this
@joshsh
Owner

No, it doesn't.

@okram
Owner

Doh. This is fixed now with Neo4jGraph.checkElementInTransaction(boolean) .. the problem was I didn't call the right contructor. It should work now.

I had this:

return new Neo4jVertexIterable(this.rawGraph.index().getNodeAutoIndexer().getAutoIndex().get(key, value), this);

Instead of this:

return new Neo4jVertexIterable(this.rawGraph.index().getNodeAutoIndexer().getAutoIndex().get(key, value), this, this.checkElementsInTransaction());

@okram okram closed this
@joshsh
Owner

And like magic, Neo4jGraphSailTest passes :-) :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.