graph icon indicating copy to clipboard operation
graph copied to clipboard

Add an example of using sack() with predicates

Open krlawrence opened this issue 5 years ago • 2 comments

Add an example that shows how to compare a property with the contents of a sack. Something like this needs to be added.

gremlin> g.withSack(6).V().hasLabel('airport').as('a').where(gt('a')).by('runways').by(sack())
==>v[8]
==>v[18]

krlawrence avatar Dec 26 '19 17:12 krlawrence

Keep in mind that any .as('something') will enable (partial) path tracking. You want to prevent path tracking whenever possible, thus the better solution would be:

g.withSack(6).V().hasLabel('airport').
  filter(project('a','b').
           by('runways').
           by(sack()).
         where('a', gt('b')))

dkuppitz avatar Dec 27 '19 17:12 dkuppitz

Thanks Daniel for the reminder. I'll do examples of each with some discussion of why one is preferable over the other. I probably also need to go back and reinforce path tracking overhead some more in a few places.

krlawrence avatar Dec 27 '19 17:12 krlawrence

Closing as this is fixed and work has now started on the second edition. There will likely be one final release of the v283 first edition line before the V2 branch becomes the second edition. That release will include these fixes.

krlawrence avatar Sep 23 '23 18:09 krlawrence