Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 155: Updated JanusGraphStepStrategy to fold hasId steps into JanusGraphStep #159

Merged
merged 1 commit into from
Mar 18, 2017

Conversation

twilmes
Copy link
Contributor

@twilmes twilmes commented Mar 8, 2017

This PR updates the JanusGraphStepStrategy to fold hasId steps into JanusGraphStep. This was causing issues with bulk loading via the BulkLoaderVertexProgram. HasIdStep was not folded in so full graph scans were being triggered on id lookups. This did not effect traversals of the form g.V(id), just g.V().hasId(id).

I made a few other small updates as part of this. First, it appeared that JanusGraphStepStrategyTest had some spurious annotations on it that were causing it to not run. I removed those so it will be run now and added in a test case for hasId folding. I also removed unnecessary publics from the HasStepFolder interface.

@twilmes
Copy link
Contributor Author

twilmes commented Mar 9, 2017

Pushed another commit that refactors the JanusGraphStepStrategyTest to the TinkerPop strategy testing style which I think is easier to follow and provides better coverage.

@pluradj
Copy link
Member

pluradj commented Mar 14, 2017

This query throws an exception:

gremlin> g.V().has("name", "marko").or().has("name", "vadas")
JanusGraph does not support the given predicate: org.apache.tinkerpop.gremlin.process.traversal.util.OrP$OrBiPredicate@5349b246
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.IllegalArgumentException: JanusGraph does not support the given predicate: org.apache.tinkerpop.gremlin.process.traversal.util.OrP$OrBiPredicate@5349b246
	at org.janusgraph.graphdb.query.JanusGraphPredicate$Converter.convert(JanusGraphPredicate.java:116)
	at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.lambda$new$49(JanusGraphStep.java:64)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:136)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:179)
	at org.apache.tinkerpop.gremlin.console.Console$_closure3.doCall(Console.groovy:220)

Traversal strategy seems ok

Original Traversal                          [GraphStep(vertex,[]), HasStep([name.eq(marko)]), OrStep, HasStep([name.eq(vadas)])]

ConnectiveStrategy                    [D]   [GraphStep(vertex,[]), OrStep([[HasStep([name.eq(vadas)])], [HasStep([name.eq(marko)])]])]
IncidentToAdjacentStrategy            [O]   [GraphStep(vertex,[]), OrStep([[HasStep([name.eq(vadas)])], [HasStep([name.eq(marko)])]])]
InlineFilterStrategy                  [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
MatchPredicateStrategy                [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
RepeatUnrollStrategy                  [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
PathRetractionStrategy                [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
AdjacentToIncidentStrategy            [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
RangeByIsCountStrategy                [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
FilterRankingStrategy                 [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
LazyBarrierStrategy                   [O]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
AdjacentVertexFilterOptimizerStrategy [P]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
JanusGraphLocalQueryOptimizerStrategy [P]   [GraphStep(vertex,[]), HasStep([name.or(eq(vadas), eq(marko))])]
JanusGraphStepStrategy                [P]   [JanusGraphStep([],[name.or(eq(vadas), eq(marko))])]
ProfileStrategy                       [F]   [JanusGraphStep([],[name.or(eq(vadas), eq(marko))])]
StandardVerificationStrategy          [V]   [JanusGraphStep([],[name.or(eq(vadas), eq(marko))])]

Final Traversal                             [JanusGraphStep([],[name.or(eq(vadas), eq(marko))])]

The same query works on TinkerGraph with TP 3.2.3, and on JanusGraph (with the WARN) before applying this PR.

@jerryjch jerryjch mentioned this pull request Mar 14, 2017
@twilmes
Copy link
Contributor Author

twilmes commented Mar 14, 2017

Good catch, I was folding in HasContainers too aggressively. Found this other issue though which looks like it's occurring straight off of master. I'll see if I can fix as part of this ticket.

gremlin> g.V().has("name","marko").or().has("name","vadas")
11:40:35 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>v[4160]
==>v[4200]
gremlin> g.V().has("name","marko").or().has("name","vadas").count()
11:40:38 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>v[4160]
==>v[8296]
==>v[4272]
==>v[4264]
==>v[4200]
==>v[4280]
gremlin>

@janusgraph-bot
Copy link

Committer of one or more commits is not listed as a CLA signer, either individual or as a member of an organization.

@janusgraph-bot janusgraph-bot added cla: no This PR is not compliant with the CLA and removed cla: yes This PR is compliant with the CLA labels Mar 15, 2017
* hasId folded into JanusGraphStep to prevent full scan
* Refactored JanusGraphStepStrategyTest to use TinkerPop strategy testing approach
@janusgraph-bot janusgraph-bot added cla: yes This PR is compliant with the CLA and removed cla: no This PR is not compliant with the CLA labels Mar 15, 2017
@twilmes
Copy link
Contributor Author

twilmes commented Mar 15, 2017

Pushed a fix so that foldId only folds id lookups and foldHasContainers handles other predicates. That previous issue I noted is actually expected behavior given that the query uses the infix notation of the 'OrStep' so no changes were required. I did find cases where further predicate folding should occur but entered that as issue #163.

Copy link
Member

@pluradj pluradj left a comment

Choose a reason for hiding this comment

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

Thanks for opening up the other issue.
The latest push looks good to me.
VOTE: +1

Copy link

@amcp amcp left a comment

Choose a reason for hiding this comment

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

lgtm, i like the incremental improvement on existing code you do as well.

@twilmes twilmes merged commit 15896b7 into JanusGraph:master Mar 18, 2017
@sjudeng
Copy link
Contributor

sjudeng commented Apr 2, 2017

@twilmes Sorry I know this PR is merged but could you explain a little on the refactoring of JanusGraphStepStrategyTest you did here?

Before this update JanusGraphStepStrategyTest was run with ProcessStandardSuite and resulted in 605 tests being run. With this update the class is no longer run with ProcessStandardSuite and so only the 15 tests in the class are run.

I'm interested because one of the issues in updating to TinkerPop 3.2.4 had been test errors/failures in ProfileTest when run through JanusGraphStepStrategyTest. Now that's no longer run so the error is gone. On the one hand I'm happy the error is gone but on the other hand I feel compelled to double check that something isn't being hidden here. For what it's worth ProfileTest is already run (I think without error) in numerous other tests suites, including InMemoryJanusGraphProcessTest, BerkeleyJanusGraphProcessTest, etc..

Update: I am having ProfileTest issues with 3.2.4 elsewhere so this question is moot on that basis. Still curious to make sure nothing was lost in JanusGraphStepStrategyTest though.

@NkululekoThangelane
Copy link

Hi is there any work happening regarding a Web interface for JanusGraph

@sjudeng
Copy link
Contributor

sjudeng commented Apr 2, 2017

@NkululekoThangelane Gremlin Server provides a web service for executing queries. But if you can post your question on the user list or chat room you might get more information on this (or other options).

bwatson-rti-org pushed a commit to bwatson-rti-org/janusgraph that referenced this pull request Mar 9, 2019
Issue 155: Updated JanusGraphStepStrategy to fold hasId steps into JanusGraphStep
micpod pushed a commit to micpod/janusgraph that referenced this pull request Nov 5, 2019
Issue 155: Updated JanusGraphStepStrategy to fold hasId steps into JanusGraphStep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR is compliant with the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants