-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more examples to local collections discussion. Start discussion o…
…f TInkerPop 3.4
- Loading branch information
1 parent
87200f1
commit 277eefb
Showing
1 changed file
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ PRACTICAL GREMLIN: An Apache TinkerPop Tutorial | |
=============================================== | ||
Kelvin R. Lawrence <[email protected]> | ||
//v281 (TP 3.3.5), January 28th 2019 | ||
v282-preview, March 2nd 2019 | ||
v282-preview, March 31st 2019 | ||
// vim: set tw=85 cc=+1 wrap spell redrawtime=20000: | ||
//Sat Mar 02, 2019 10:04:01 | ||
// Sun Mar 31, 2019 10:36:57 | ||
//:Author: Kelvin R. Lawrence | ||
//:Email: [email protected] | ||
:Numbered: | ||
|
@@ -25,8 +25,8 @@ v282-preview, March 2nd 2019 | |
:doctype: book | ||
:icons: font | ||
//:pdf-page-size: Letter | ||
:draftdate: March 2nd 2019 | ||
:tpvercheck: 3.3.5 | ||
:draftdate: March 31st 2019 | ||
:tpvercheck: 3.4.0 | ||
|
||
// NOTE1: I updated the paraiso-dark style so that source code with a style of text | ||
// has a white foreground color. The default was unreadable, | ||
|
@@ -163,8 +163,9 @@ examples presented will work unmodified with the `air-routes.graphml` file loade | |
the Gremlin console running with a TinkerGraph. How to set that environment up is | ||
covered in the <<gremlininstall>> section below. | ||
|
||
NOTE: The examples in this book have now been updated and tested using Apache | ||
TinkerPop release {tpvercheck}. | ||
NOTE: The examples in this book have been tested using Apache TinkerPop release | ||
{tpvercheck}. However, work remains to be done to add coverage of new features in | ||
that release to the book. | ||
|
||
TinkerGraph is an 'in-memory' graph, meaning nothing gets saved to disk | ||
automatically. It is shipped as part of the Apache TinkerPop 3 download. The | ||
|
@@ -294,6 +295,20 @@ Change history:: | |
on. | ||
- https://github.com/krlawrence/graph/blob/master/ChangeHistory.md | ||
|
||
[[tp34intro]] | ||
A word about TinkerPop 3.4 | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
A major update to Apache TinkerPop, release 3.4.0 was released in January 2019. The | ||
examples in this book have been tested with TinkerPop 3.4.0 but the text does not yet | ||
include coverage of all the new features, changes and deprecations introduced with | ||
that release. Be aware also that given the scope of the 3.4.0 release it may take a while | ||
before all of the vendor and open source graph implementations that support Apache | ||
TinkerPop have caught up with all of these new features. I plan to add coverage of | ||
these features over the coming weeks to the book. I also plan to add additional | ||
sample code to the `sample-code` folder. By way of a start I have recently added a | ||
sample called `nested-repeat.groovy` that demonstrates the use of the new nested | ||
repeat step capability from the Gremlin console. | ||
|
||
[[whygraph]] | ||
So what is a graph database and why should I care? | ||
|
@@ -10267,6 +10282,37 @@ g.V().has('airport','country','IE'). | |
[KIR,ORK] | ||
---- | ||
|
||
You can combine the 'limit' and 'tail' steps with 'local' scope to extract the | ||
beginning or ending entries from a list of values as shown below. The following | ||
query creates a list containing the IATA codes for all airports in Texas. | ||
|
||
[source,groovy] | ||
---- | ||
g.V().has('region','US-TX').values('code').fold() | ||
|
||
[AUS,DFW,IAH,SAT,HOU,ELP,DAL,LBB,HRL,MAF,CRP,ABI,ACT,CLL,BPT,AMA,BRO,GGG,GRK,LRD,MFE,SJT,SPS,TYR,VCT,AFW] | ||
---- | ||
|
||
Using 'local' scope with a 'limit' step we can extract just the first two entries | ||
from the list. | ||
|
||
[source,groovy] | ||
---- | ||
g.V().has('region','US-TX').values('code').fold().limit(local,2) | ||
|
||
[AUS,DFW] | ||
---- | ||
|
||
Likewise, using 'local' scope with a 'tail' step we can extract just the last two | ||
entries from the list. | ||
|
||
[source,groovy] | ||
---- | ||
g.V().has('region','US-TX').values('code').fold().tail(local,2) | ||
|
||
[VCT,AFW] | ||
---- | ||
|
||
Lastly, let's take a look at how 'local' scope can be used with a 'dedup' step. The | ||
query below finds airports in the US and produces a sorted list of the unique region | ||
codes by only allowing one airport from each region to proceed to the next steps of | ||
|
277eefb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very early start to TP 3.4 coverage. Lots to do here #115