Gremlin Recipes: 8 – Sack() Operator
This blog post discusses the sack() step in Gremlin, a query language for traversing graphs. The sack() step was introduced to help users solve problems more efficiently by using local data structures relative to each traverser instead of global ones. Sacks can contain any type of data structure and are defined right after the traversal object. The complete signature of the withSack() step is withSack(default_data_structure, split_operator, merge_operator). To mutate the content of a sack, users can use the step sack(bi-function).by(projection_axis). The sack data structure can be accessed at any time by calling the step sack(). An example is provided to compute Blade Runner's average rating using sack(). Finally, an example demonstrates how to find the shortest path between South Kensington and Marble Arch tube stations using sack() in Gremlin.
Company
DataStax
Date published
Sept. 24, 2017
Author(s)
Duy Hai Doan
Word count
868
Language
English
Hacker News points
None found.