Skip to content

Commit 1288b9e

Browse files
committedJan 28, 2025
minor additions for strategies and filtering map keys
1 parent b509968 commit 1288b9e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 

‎book/Section-Miscellaneous-Queries-Results.adoc

+11
Original file line numberDiff line numberDiff line change
@@ -4412,6 +4412,17 @@ extremely long time. In many ways the concept of "longest path" can be viewed as
44124412
anti pattern. This is especially true in highly connected graphs of which
44134413
`air-routes` is an example.
44144414

4415+
As a final point about the prior example, we recall the "<<traversal-strategies>>"
4416+
section, where we learned that TinkerPop applies some changes to the way a traversal
4417+
is written just before it is iterated to optimize performance where it can. The prior
4418+
example demonstrates a case where certain query patterns will prevent a particular
4419+
strategy from being applied. Normally, the 'repeat().times()' pattern will result in
4420+
the contents of 'repeat' being expanded, where 'repeat(out()).times(2)' becomes,
4421+
'out().out()' which is more efficient for TinkerPop to execute. But the presence of
4422+
'dedup()' precludes that transformation to get the query semantics that are
4423+
presented. This sort of information can become useful when you are looking for your
4424+
own query optimizations.
4425+
44154426
[[unwantededges]]
44164427
Finding unwanted parallel edges
44174428
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

‎book/Section-Writing-Gremlin-Queries.adoc

+20
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,26 @@ g.V().has('code','AUS').valueMap().select('code','icao','desc')
17551755
[code:[AUS],icao:[KAUS],desc:[Austin Bergstrom International Airport]]
17561756
----
17571757

1758+
As an additional example of Gremlin's flexibility, note that you can also restrict
1759+
the selected keys to all but those you specify.
1760+
1761+
[source,groovy]
1762+
----
1763+
g.V('3').valueMap().as('vm').unfold().
1764+
filter(select(keys).is(without('city','desc')))
1765+
1766+
country=[US]
1767+
code=[AUS]
1768+
longest=[12250]
1769+
elev=[542]
1770+
icao=[KAUS]
1771+
lon=[-97.6698989868164]
1772+
type=[airport]
1773+
region=[US-TX]
1774+
runways=[2]
1775+
lat=[30.1944999694824]
1776+
----
1777+
17581778
If you are reading the output of queries that use 'valueMap' on the Gremlin console,
17591779
it is sometimes easier to read the output if you add an 'unfold' step to the end of
17601780
the query as follows. The 'unfold' step will unbundle a collection for us. You will

0 commit comments

Comments
 (0)
Failed to load comments.