Skip to content

Commit

Permalink
Minor reformatting for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
spmallette committed Jan 25, 2024
1 parent af612c1 commit 8d9cac6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions book/Section-Beyond-Basic-Queries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ that in the very last example of the prior section where we fed the 'german' var
back in to a traversal. By way of another simple example, the code below stores the
result of the first query in the variable 'austin' and then uses it to look for
routes from Austin in second query. Notice how we do this by passing the variable
containing the Austin vertex into the 'V()' step.
containing the Austin vertex into the 'V' step.

[source,groovy]
----
Expand All @@ -479,8 +479,8 @@ containing the Austin vertex into the 'V()' step.
----

You can take this technique one step further and pass an entire saved list of
vertices to 'V()'. In the next example we first generate a list of all airports that
are in Scotland and then pass that entire list into 'V()' to first of all count how
vertices to 'V'. In the next example we first generate a list of all airports that
are in Scotland and then pass that entire list into 'V' to first of all count how
many routes there are from those airports and then we start another query that looks
for any route from those airports to airports in Germany.

Expand Down Expand Up @@ -629,8 +629,8 @@ step.
g.V().has('code','DFW').addE('route').to(xyz)
----

We could have written the previous line to use a second 'V()' step if we had not
previously saved anything in a variable. Note that while this use of a second 'V()'
We could have written the previous line to use a second 'V' step if we had not
previously saved anything in a variable. Note that while this use of a second 'V'
step will work locally, if you are sending queries to a Gremlin Server (a topic we
will discuss later in this book) this syntax is not supported and will not work.

Expand Down Expand Up @@ -4195,7 +4195,7 @@ have been used instead.
g.V().hasLabel('airport').filter{it.get().property('city').value() =="London"}
----

Here is the same query just using the 'has()' step. This is a case where we
Here is the same query just using the 'has' step. This is a case where we
should not be using a lambda function as Gremlin can handle this just fine all
by itself.

Expand Down Expand Up @@ -4768,7 +4768,7 @@ g.V().has('airport', 'desc', TextP.containing('Dallas'))

Where things get even more interesting is when you want to use a regular
expression as part of a query. Note that the first example below could also be
achieved using a Gremlin 'within()' step as it is still really doing exact
achieved using a Gremlin 'within' step as it is still really doing exact
string comparisons but it gives us a template for how to write any query
containing a regular expression. The example that follows finds all airports
in cities with names that begin with 'Dal' so it will find Dallas, Dalaman, Dalian,
Expand Down
4 changes: 2 additions & 2 deletions book/Section-Introducing-Gremlin-Server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ Once the 'Cluster.Builder' instance has been setup we can use it to create our
Lastly, we need to setup a 'GraphTraversalSource' object for the Gremlin Server
hosted graph that we will be working with. This object is often named "g" by
convention and is typically created using the statically imported 'traversal()'
method which in turn allows the call to 'with()' to bind the traversal source to a
graph. We've seen 'with()' take a graph instance before, but this time we will use it
method which in turn allows the call to 'with' to bind the traversal source to a
graph. We've seen 'with' take a graph instance before, but this time we will use it
with a reference to a remote connection to a graph in Gremlin Server. Note that the
cluster instance that we just created is passed in as a parameter. While this looks a
little complicated it is really not a lot different than when we connect to a local
Expand Down
10 changes: 5 additions & 5 deletions book/Section-Moving-Beyond.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import statements.

Take particular note of the rather odd import of the class called +++"__"+++
(underscore underscore) on the second line. This is required to enable calling
methods such as 'in()' and 'out()' in a traversal where there is no prior step
methods such as 'in' and 'out' in a traversal where there is no prior step
to "dot" attach them to (such as inside of a 'repeat' step). If you prefer you
can statically import the +++"__"+++ class which will make explicit use of
+++".__"+++ in your code unnecessary except where you are faced with reserved
Expand Down Expand Up @@ -117,7 +117,7 @@ located at https://github.com/krlawrence/graph/tree/main/sample-code/java.
Lastly in this initial class definition we create a 'GraphTraversalSource' and we
make a Gremlin query to get the property 'valueMap' for the Austin airport vertex and
print it. The 'toString' method provided by the 'Map' should give us some useful
output. Take note of the call to 'next()'. This terminates the graph traversal and
output. Take note of the call to 'next'. This terminates the graph traversal and
causes the result to be returned. If this call is left off you will not get back what
you were expecting!

Expand Down Expand Up @@ -267,7 +267,7 @@ There are 221 routes from Dallas

Let's now add some code to retrieve the airport IATA codes of these 221 airports that
we can fly to non stop from DFW. Note that this time we ended our query with a call
to the 'toList()' method. This will terminate the traversal, and as the name implies,
to the 'toList' method. This will terminate the traversal, and as the name implies,
return the results to us in a list. An 'order' step is used in the traversal so that
we get the airport codes back in ascending order.

Expand Down Expand Up @@ -318,7 +318,7 @@ readability.
The final part of our first Java program shows how to perform a simple 'repeat'
operation. The code below will look for any cities in the UK that you can get to from
Austin with one stop on the way. A key thing to note here is that we have to prefix
the call to 'out()' with the strangely named class +++"__."+++ that we mentioned at
the call to 'out' with the strangely named class +++"__."+++ that we mentioned at
the start of this discussion of using Java with TinkerPop. If you do not include the
+++"__."+++ prefix you will get a compilation error as the compiler does not know
where the 'out' step is from.
Expand Down Expand Up @@ -810,7 +810,7 @@ source object and then uses a traversal to create a small graph.
NOTE: The source code in this section comes from the 'CreateGraph.java' sample
located at https://github.com/krlawrence/graph/tree/main/sample-code/java.

Note the call to 'iterate()' at the end of the traversal. When running as a
Note the call to 'iterate' at the end of the traversal. When running as a
standalone application this is necessary. This is another of those little things that
the Gremlin Console does for you without you realizing it that we have to remember to
do ourselves when not running inside the console.
Expand Down
10 changes: 5 additions & 5 deletions book/Section-Writing-Gremlin-Queries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ follows:
g.V().has('code','AUS').out().out().out().has('code','AGR').path().by('code')
----

Adding or removing hops is as simple as adding or removing one or more of the 'out()'
Adding or removing hops is as simple as adding or removing one or more of the 'out'
steps which is a lot simpler than having to add additional 'join' clauses to our SQL
query. This is a simple example, but as queries get more and more complicated in
heavily connected data sets like networks, the SQL queries get harder and harder to
Expand Down Expand Up @@ -1784,7 +1784,7 @@ g.E(5161).valueMap(true)
----

There are other ways to control the results that a 'valueMap' step return using
the 'with()' modulator.
the 'with' modulator.

NOTE: The valueMap configuration options are described in the official
documentation at the following link
Expand Down Expand Up @@ -2251,7 +2251,7 @@ In looking at the above code, you might wonder where the 'traversal()' method co
from. This function is a member of the 'AnonymousTraversalSource' class and it is
considered good form to statically import it so that it can be called without the
class. Calling 'traversal()' constructs an anonymous traversal source which is like
having a graph traversal source without a connection to a graph. Calling 'with()' on
having a graph traversal source without a connection to a graph. Calling 'with' on
this object binds it to a particular graph data source and then "g" is ready for you
to write your queries.

Expand Down Expand Up @@ -2463,7 +2463,7 @@ g.V().hasId(6).out().has(id,lt(46)).path().by('code')
g.V().hasId(6).out().hasId(lt(46)).path().by('code')
----

You can also pass a single ID or multiple IDs directly into the 'V()' step.
You can also pass a single ID or multiple IDs directly into the 'V' step.
Take a look at the two examples below.

[source,groovy]
Expand Down Expand Up @@ -4395,7 +4395,7 @@ that shows how to perform the query shown above in a Java program.
There are several things about this query that are interesting. Firstly because we
are comparing the results of two 'values' steps we do not provide a parameter to the
'by' step as we do not need to provide a property key. Secondly, we use a second
'V()' step in the query to find all the airports that have the same airport code as
'V' step in the query to find all the airports that have the same airport code as
Nice. Note that this also means that Nice is included in the results. Lastly we wrap
the part of the query that prepares the output in a form we want in a 'local' step so
that a separate list is created for each airport.
Expand Down

0 comments on commit 8d9cac6

Please sign in to comment.