krlawrence / graph

Practical Gremlin - An Apache TinkerPop Tutorial
Apache License 2.0
836 stars 254 forks source link

Add an example showing how to merge two valueMap results #218

Closed krlawrence closed 10 months ago

krlawrence commented 3 years ago

Add an example near section 4.16 showing how to merge two valueMap results

For example

gremlin> g.V(3,4).valueMap().unfold().group().by(keys).by(select(values).unfold().fold())

==>[country:[US,US],code:[AUS,BNA],longest:[12250,11030],city:[Austin,Nashville],elev:[542,599],icao:[KAUS,KBNA],lon:[
-97.6698989868164,-86.6781997680664],type:[airport,airport],region:[US-TX,US-TN],runways:[2,4],lat:[30.1944999694824,3
6.1245002746582],desc:[Austin Bergstrom International Airport,Nashville International Airport]]     
krlawrence commented 1 year ago

This might also be a good place to mention fold(addAll)

krlawrence commented 1 year ago
gremlin> g.inject([a:1],[b:2]).fold([],addAll)
==>[[a:1],[b:2]]