sack / withSack MergeOperator

52 views
Skip to first unread message

Michael Pollmeier

unread,
Mar 27, 2017, 8:26:49 PM3/27/17
to Gremlin-users
I am having trouble understanding the documentation on MergeOperator for withSack / sack.
http://tinkerpop.apache.org/docs/current/reference/#sack-step

1) sack takes the MergeOperator as the third argument. The examples apparently use `sum` as the mergeOperator, but define it as the second argument.

2) `sum` doesn't seem to have any effect. I get the same results when not passing it to `withSack`:
gremlin> g.withSack(1.0f,sum).V(1).local(outE('knows').barrier(normSack).inV()).sack()
==>0.5
==>0.5
gremlin> g.withSack(1.0f).V(1).local(outE('knows').barrier(normSack).inV()).sack()
==>0.5
==>0.5

Unfortunately SackStepTest is essentially empty.
Is there any other place where I can see a working example?
Does the documentation need an update?

Marko Rodriguez

unread,
Mar 27, 2017, 9:17:56 PM3/27/17
to gremli...@googlegroups.com
Hi,

SackStepTest just tests the hashcodes of the step. You should look at SackTest.

If you don’t find what you are looking for, say so and I can go into more depth for you.

HTH,
Marko.
--
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/24c3faaa-9403-4756-b1bd-88666156b7e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Pollmeier

unread,
Mar 27, 2017, 10:04:10 PM3/27/17
to gremli...@googlegroups.com
Thank you, now I found a use case where the mergeOperator actually had
an impact. Might might be worth updating the documentation since if
people (like me) take it and play with it, it looks like it doesn't work.

E.g. here's a traversal where it _does_ have an impact:
gremlin>
g.withSack(1.0d).V(1).local(out("knows")).in("knows").barrier().sack()
==>1.0
==>1.0
gremlin> g.withSack(1.0d,
sum).V(1).local(out("knows")).in("knows").barrier().sack()
==>2.0
==>2.0

I'm happy to send you a PR for the docs, just let me know.


On 28/03/17 14:17, Marko Rodriguez wrote:
> Hi,
>
> SackStepTest just tests the hashcodes of the step. You should look at
> SackTest.
>
> If you don’t find what you are looking for, say so and I can go into
> more depth for you.
>
> HTH,
> Marko.
>
> http://markorodriguez.com
>
>
>
>> On Mar 27, 2017, at 6:26 PM, Michael Pollmeier
>> <mic...@michaelpollmeier.com <mailto:mic...@michaelpollmeier.com>>
>> <mailto:gremlin-user...@googlegroups.com>.
>> <https://groups.google.com/d/msgid/gremlin-users/24c3faaa-9403-4756-b1bd-88666156b7e3%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Gremlin-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/gremlin-users/BVrJP2Lwwck/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> gremlin-user...@googlegroups.com
> <mailto:gremlin-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gremlin-users/36ADEF85-DC42-4D04-8352-853CBC95A5BC%40gmail.com
> <https://groups.google.com/d/msgid/gremlin-users/36ADEF85-DC42-4D04-8352-853CBC95A5BC%40gmail.com?utm_medium=email&utm_source=footer>.

Michael Pollmeier

unread,
Mar 27, 2017, 10:15:11 PM3/27/17
to Gremlin-users
Actually, even simpler:

gremlin> g.withSack(1.0d, sum).V(1).out("knows").in("knows").sack()
==>2.0
==>2.0
gremlin> g.withSack(1.0d).V(1).out("knows").in("knows").sack()
==>1.0
==>1.0

Marko Rodriguez

unread,
Mar 28, 2017, 9:08:01 AM3/28/17
to gremli...@googlegroups.com
Hi,

PR to the docs would be great. Or, since its so simple, just CTR (“commit then review”) it.

Thanks Michael,
Marko.
--
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/47fed552-51a9-46b1-90c0-e18fc9d9c9f1%40googlegroups.com.

Michael Pollmeier

unread,
Mar 28, 2017, 5:44:18 PM3/28/17
to gremli...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages