Tinkerpop 3.1.1 OLAP (Spark) Gremlin error on filter query: The properties of an adjacent vertex can not be read or updated

247 views
Skip to first unread message

Jen

unread,
Jun 2, 2016, 9:24:54 AM6/2/16
to Gremlin-users
Hi,

I am trying to do a filter query in OLAP (Spark) Gremlin which uses a filter where I'm trying to read a vertex property and getting an error. On the Grateful Dead example graph, I'm trying to filter song vertices such that songs are kept which are not covers or are not sung by Garcia or Weir. I've written the query like this:
gremlin> g.V().hasLabel('song').filter(has('songType',without('cover')).or().match(
    __.as('songV').out('sungBy').as('sungV'),
    __.as('sungV').values('name').as('artistName')).
select('artistName').where(without('Garcia','Weir')))
I use the match statement to allow traversals beyond the local star graph. And I get the exception (full stack trace is below) java.lang.UnsupportedOperationException: The properties of an adjacent vertex can not be read or updated. 

Is this related to https://issues.apache.org/jira/browse/TINKERPOP-691? Is this a bug in Tinkerpop, or am I writing my query wrong? If it's a bug, is there any workaround for OLAP TP 3.1.1?

-Jen


Stack trace:
java.lang.UnsupportedOperationException: The properties of an adjacent vertex can not be read or updated
        at org.apache.tinkerpop.gremlin.process.computer.GraphComputer$Exceptions.adjacentVertexPropertiesCanNotBeReadOrUpdated(GraphComputer.java:202)
        at org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph$ComputerAdjacentVertex.properties(ComputerGraph.java:471)
        at org.apache.tinkerpop.gremlin.structure.Element.values(Element.java:107)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep.flatMap(PropertiesStep.java:50)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:47)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:54)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep$MatchEndStep.processNextStart(MatchStep.java:460)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:147)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep.standardAlgorithm(MatchStep.java:313)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep.processNextStart(ComputerAwareStep.java:47)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:54)
        at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:36)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:147)
        at org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil.test(TraversalUtil.java:84)
        at org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep.processNextStart(OrStep.java:41)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:147)
        at org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil.test(TraversalUtil.java:84)
        at org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep.filter(TraversalFilterStep.java:46)
        at org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep.processNextStart(FilterStep.java:38)
        at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:140)
        at java.util.Iterator.forEachRemaining(Iterator.java:115)
        at org.apache.tinkerpop.gremlin.process.computer.traversal.TraverserExecutor.lambda$execute$337(TraverserExecutor.java:83)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at org.apache.tinkerpop.gremlin.process.computer.traversal.TraverserExecutor.execute(TraverserExecutor.java:80)
        at org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram.execute(TraversalVertexProgram.java:166)
        at org.apache.tinkerpop.gremlin.spark.process.computer.SparkExecutor.lambda$null$17(SparkExecutor.java:92)
        at org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils$3.next(IteratorUtils.java:232)
        at scala.collection.convert.Wrappers$JIteratorWrapper.next(Wrappers.scala:42)
        at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
        at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:209)
        at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:73)
        at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:73)
        at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
        at org.apache.spark.scheduler.Task.run(Task.scala:88)
        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Daniel Kuppitz

unread,
Jun 2, 2016, 12:23:30 PM6/2/16
to gremli...@googlegroups.com
Hi Jen,

am I writing my query wrong?

Yes. The query is bad for OLAP, because a local traversal traverses past the local star-graph. The problem here is that the match() step is already nested (local traversal) and you're trying to traverse out() and access the property "artistName" of the adjacent vertex.

Here's what I would do:

g.V().hasLabel("song").as("song").choose(has("songType", neq("cover")),
    identity(), out("sungBy")).
  where(hasLabel("song").or().has("name", without("Garcia","Weir"))).
  select("song").dedup()

There's also a match()-only solution, but it would require that there's always at least one "sungBy" edge for every song. Also note that you could make your query work, if you would know the id of Garcia and Weir upfront.

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/6f296f22-5da0-4713-b589-9cce1964e354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marko Rodriguez

unread,
Jun 2, 2016, 1:37:46 PM6/2/16
to gremli...@googlegroups.com
Hello,

Can one of you make a ticket in JIRA for the simplest traversal that exposes this problem? The compiler should have picked up that you were leaving the star graph and thrown a compile-time exception. In other words, this shouldn't have been a runtime exception.

Thanks,
Marko.

Daniel Kuppitz

unread,
Jun 2, 2016, 2:10:28 PM6/2/16
to gremli...@googlegroups.com

Marko Rodriguez

unread,
Jun 2, 2016, 4:01:31 PM6/2/16
to gremli...@googlegroups.com
Fixed.


This is in master/. The problem is that MatchStep traversals are not isolated like union() or coalesce()… instead, they will be concatenated in some arbitrary order. Thus, match() is much like RepeatStep (save that in repeat(), its the same traversal being concatenated with itself). Therefore, in TraversalHelper.isLocalStarGraph(), the same logic I use for RepeatStep should also apply to MatchStep. Simple fix. I added the failing test case and now your get a compile-time instead of a runtime error.

Enjoy,
Marko.

Jen

unread,
Jun 8, 2016, 9:31:50 AM6/8/16
to Gremlin-users
Great, thanks for your help, Marko and Daniel. The query Daniel suggested works great for me and glad to hear the error message is fixed too!

Thanks,
Jen
Reply all
Reply to author
Forward
0 new messages