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

Another issue with P.without #321

Closed
Easy65 opened this issue Dec 4, 2018 · 4 comments
Closed

Another issue with P.without #321

Easy65 opened this issue Dec 4, 2018 · 4 comments
Assignees
Labels

Comments

@Easy65
Copy link

Easy65 commented Dec 4, 2018

Hi Pieter,

I found another issue with P.without. There seems to be a wrong optimization it the collection is empty. Here is some code that shows the issue:

` String name = "name";
String prop = "prop";
Vertex v1 = g.addVertex(T.label, "LABEL", name, "v1");
Vertex v2 = g.addVertex(T.label, "LABEL", name, "v2", prop, "p2");
Vertex v3 = g.addVertex(T.label, "LABEL", name, "v3", prop, "p3");
Vertex v4 = g.addVertex(T.label, "LABEL", name, "v4", prop, "");
Vertex v5 = g.addVertex(T.label, "LABEL", name, "v5");

			v1.addEdge("EDGELABEL", v2);
			v1.addEdge("EDGELABEL", v3);
			v1.addEdge("EDGELABEL", v4);
			v1.addEdge("EDGELABEL", v5);
			
			g.tx().commit();
			
			// returns v2, v3, v4, v5
			GraphTraversal<Vertex, Vertex> gt = g.traversal().V(v1).out("EDGELABEL");
			while (gt.hasNext()) {
				Vertex v = gt.next();
				System.out.println(v.property("name"));
			}
			System.out.println();
			// returns v2, v3, v4
			gt = g.traversal().V(v1).out("EDGELABEL").has(prop);
			while (gt.hasNext()) {
				Vertex v = gt.next();
				System.out.println(v.property("name"));
			}
			System.out.println();

			// In my opinion, the following 2 testcases should return the same, but do not.
			// There is probably some optimization that removes the whole has condition
			// in case of an empty collection, but correct would be to remove the predicate only
			// or set it to true
			
			// returns v2, v3, v4, v5 (v5 should not be in the result)
			gt = g.traversal().V(v1).out("EDGELABEL").has(prop, P.without(Collections.emptySet()));
			while (gt.hasNext()) {
				Vertex v = gt.next();
				System.out.println(v.property("name"));
			}
			System.out.println();
			
			// returns v2, v3, v4
			Collection<String> excl = new HashSet<>();
			excl.add("p7");
			gt = g.traversal().V(v1).out("EDGELABEL").has(prop, P.without(excl));
			while (gt.hasNext()) {
				Vertex v = gt.next();
				System.out.println(v.property("name"));
			}
			System.out.println();
			
			// returns v2, v3
			excl = new HashSet<>();
			excl.add("");
			gt = g.traversal().V(v1).out("EDGELABEL").has(prop, P.without(excl));
			while (gt.hasNext()) {
				Vertex v = gt.next();
				System.out.println(v.property("name"));
			}
			System.out.println();

`

@pietermartin pietermartin self-assigned this Dec 9, 2018
@pietermartin
Copy link
Owner

You were right, the HasContainer was removed for P.without(Collections.emptySet()) I am now replacing it with new HasContainer(hasContainer.getKey(), new P<>(Existence.NOTNULL, null))

Please check on your side if its behaving as expected.

@pietermartin pietermartin reopened this Dec 9, 2018
@Easy65
Copy link
Author

Easy65 commented Dec 11, 2018

I have some trouble testing this. I switched from 2.0.0 to 2.0.1-SNAPSHOT and maven seems to get a version from Dec. 9, but my test gets stuck in some strange lock situation.
I then removed the test database and recreated it, but when I start to write into it, I get this error:
Deleting database contents and inserting test data...
Exception in thread "main" java.lang.NoSuchFieldError: asc
at org.umlg.sqlg.sql.parse.SchemaTableTree.toOrderByClause(SchemaTableTree.java:1402)
at org.umlg.sqlg.sql.parse.SchemaTableTree.constructSelectSinglePathSql(SchemaTableTree.java:1112)
at org.umlg.sqlg.sql.parse.SchemaTableTree.constructSinglePathSql(SchemaTableTree.java:816)
at org.umlg.sqlg.sql.parse.SchemaTableTree.constructSinglePathSql(SchemaTableTree.java:794)
at org.umlg.sqlg.sql.parse.SchemaTableTree.constructSql(SchemaTableTree.java:392)
at org.umlg.sqlg.strategy.SqlgSqlExecutor.executeRegularQuery(SqlgSqlExecutor.java:76)
at org.umlg.sqlg.structure.SqlgCompiledResultIterator.executeRegularQuery(SqlgCompiledResultIterator.java:251)
at org.umlg.sqlg.structure.SqlgCompiledResultIterator.hasNextLazy(SqlgCompiledResultIterator.java:121)
at org.umlg.sqlg.structure.SqlgCompiledResultIterator.hasNext(SqlgCompiledResultIterator.java:78)
at org.umlg.sqlg.step.SqlgGraphStep.processNextStart(SqlgGraphStep.java:80)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.fill(Traversal.java:179)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList(Traversal.java:117)
at org.umlg.sqlg.structure.topology.Topology.cacheTopology(Topology.java:1068)
at org.umlg.sqlg.structure.SqlgStartupManager.cacheTopology(SqlgStartupManager.java:158)
at org.umlg.sqlg.structure.SqlgStartupManager.loadSqlgSchema(SqlgStartupManager.java:101)
at org.umlg.sqlg.structure.SqlgGraph.open(SqlgGraph.java:250)
at org.umlg.sqlg.structure.SqlgGraph.open(SqlgGraph.java:238)

@Easy65
Copy link
Author

Easy65 commented Dec 11, 2018

Problem found, I did not switch to Tinkerpop 3.3.4. Now it works and the P.without works as expected.
Thanks a lot!

@pietermartin
Copy link
Owner

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants