Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Example Symbols #300

Merged
merged 11 commits into from
Jan 14, 2025
14 changes: 7 additions & 7 deletions src/main/asciidoc/api/gremlin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Example:

[source,java]
----
ResultSet result = database.query("gremlin", "g.V().has('name','Steve').has('lastName','Jobs').out('IsFriendOf')");
ResultSet result = database.query("gremlin", "g.V().has('name','Michelle').has('lastName','Besso').out('IsFriendOf')");
----

If you're application is mostly based on Gremlin, the best way is to use the ArcadeGraph class as an entrypoint. Example:

```java
try (final ArcadeGraph graph = ArcadeGraph.open("./databases/graph")) {
Vertex steveFriend = graph.traversal().V().has("name","Steve").has("lastName","Jobs").out("IsFriendOf").next();
Vertex michelleFriend = graph.traversal().V().has("name","Michelle").has("lastName","Besso").out("IsFriendOf").next();
}
```

Expand All @@ -43,7 +43,7 @@ You can also work with a remote ArcadeDB Server:
```java
try( RemoteDatabase database = new RemoteDatabase("127.0.0.1", 2480, "graph", "root", "playwithdata") ){
try (final ArcadeGraph graph = ArcadeGraph.open(database)) {
Vertex steveFriend = graph.traversal().V().has("name","Steve").has("lastName","Jobs").out("IsFriendOf").next();
Vertex michelleFriend = graph.traversal().V().has("name","Michelle").has("lastName","Besso").out("IsFriendOf").next();
}
}
```
Expand All @@ -68,10 +68,10 @@ Example:

[source,Gremlin]
----
"{gremlin} g.V().has('name','Steve').has('lastName','Jobs').out('IsFriendOf')"
"{gremlin} g.V().has('name','Michelle').has('lastName','Besso').out('IsFriendOf')"
----

ArcadeDB server will execute the query `g.V().has('name','Steve').has('lastName','Jobs').out('IsFriendOf')` using the Gremlin query language.
ArcadeDB server will execute the query `g.V().has('name','Michelle').has('lastName','Besso').out('IsFriendOf')` using the Gremlin query language.

[discrete]
==== Gremlin through HTTP/JSON
Expand All @@ -81,14 +81,14 @@ Example of executing an idempotent query with HTTP GET command:

[source,shell]
----
curl "http://localhost:2480/query/graph/gremlin/g.V().has('name','Steve').has('lastName','Jobs').out('IsFriendOf')"
curl "http://localhost:2480/query/graph/gremlin/g.V().has('name','Michelle').has('lastName','Besso').out('IsFriendOf')"
----

Example of executing a non-idempotent query (updates the database):

[source,shell]
----
curl -X POST "http://localhost:2480/command/graph" -d "{'language': 'gremlin', 'command': 'g.V().has(\"name\",\"Steve\").has(\"lastName\",\"Jobs\").out(\"IsFriendOf\")'}"
curl -X POST "http://localhost:2480/command/graph" -d "{'language': 'gremlin', 'command': 'g.V().has(\"name\",\"Michelle\").has(\"lastName\",\"Besso\").out(\"IsFriendOf\")'}"
----

[discrete]
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/api/java-ref-database-async.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Where:
Example on inserting a vertex asynchronously.

```java
final MutableVertex vertex = database.newVertex("Customer").set("name", "Elon");
final MutableVertex vertex = database.newVertex("Customer").set("name", "Albert");
database.async().createRecord(vertex,
v -> { System.out.println("Record " + v.toJSON() + " created") });
```
Expand Down
52 changes: 26 additions & 26 deletions src/main/asciidoc/api/java-tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ Now let's create two "Profile" vertices and let's connect them with the friendsh
[graphviz,dot-example,svg]
----
graph g {
Elon -- Steve [label = "IsFriendOf" dir = "both"]
Albert -- Michelle [label = "IsFriendOf" dir = "both"]
}
----

[source,java]
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
MutableVertex elon = db.newVertex("User", "name", "Elon", "lastName", "Musk").save();
MutableVertex steve = db.newVertex("User", "name", "Steve", "lastName", "Jobs").save();
elon.newEdge("IsFriendOf", steve, true, "since", 2010);
MutableVertex albert = db.newVertex("User", "name", "Albert", "lastName", "Einstein").save();
MutableVertex michelle = db.newVertex("User", "name", "Michelle", "lastName", "Besso").save();
albert.newEdge("IsFriendOf", michelle, true, "since", 2010);
});
}
----
Expand All @@ -234,7 +234,7 @@ In the code snipped above, we have just created our first graph, made of 2 verti
Vertices and documents are not persistent until you call the `save()` method.
Note the 3rd parameter in the `newEdge()` method.
It's telling to the Graph engine that we want a bidirectional edge.
In this way, even if the direction is still from the "Elon" vertex to the "Steve" vertex, we can traverse the edge from both sides.
In this way, even if the direction is still from the "Albert" vertex to the "Michelle" vertex, we can traverse the edge from both sides.
Use always bidirectional unless you want to avoid creating super-nodes when it's necessary to traverse only from one side.
Note also that we stored a property "since = 2010" in the edge.
That's right, edges can have properties like vertices.
Expand Down Expand Up @@ -263,7 +263,7 @@ You have basically three ways to do that (<<Java-API,Java API>>, <<SQL,SQL>>, ht
When using the API, when the SQL and Apache Gremlin?
The API is the very code based.
You have total control on the query/traversal.
With the SQL, you can combine the SELECT with the MATCH statement to create powerful traversals in a just few lines.
With the SQL, you can combine the `SELECT` with the `MATCH` statement to create powerful traversals in a just few lines.
You could use Apache Gremlin if you're coming from another GraphDB that supports this language.

====== Traverse via API
Expand All @@ -278,8 +278,8 @@ Example of lookup by RID:
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
// #10:232 in our example is Elon Musk's RID
Vertex elon = db.lookupByRID( new RID(db, "#10:232"), true );
// #10:232 in our example is Albert Einstein's RID
Vertex albert = db.lookupByRID( new RID(db, "#10:232"), true );
});
}
----
Expand All @@ -298,13 +298,13 @@ try( Database db = databaseFactory.open(); ){
}
----

Now we're able to load Steve's vertex in a flash by using this:
Now we're able to load Michelle's vertex in a flash by using this:

[source,java]
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
Vertex steve = db.lookupByKey( "Profile", new String[]{"name", "lastName"}, new String[]{"Steve", "Jobs"} );
Vertex michelle = db.lookupByKey( "Profile", new String[]{"name", "lastName"}, new String[]{"Michelle", "Besso"} );
});
}
----
Expand All @@ -317,8 +317,8 @@ ArcadeDB supports SQL, so try this:
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
ResultSet result = db.query( "SQL", "select from Profile where name = ? and lastName = ?", "Steve", "Jobs" );
Vertex steve = result.next();
ResultSet result = db.query( "SQL", "select from Profile where name = ? and lastName = ?", "Michelle", "Besso" );
Vertex michelle = result.next();
});
}
----
Expand All @@ -327,13 +327,13 @@ With the query approach, if an existent index is available, then it's automatica

Now that we have loaded the root vertex in memory, we're ready to do some traversal.
Before looking at the API, it's important to understand every edge has a direction: from vertex A to vertex B.
In the example above, the direction of the friendship is from "Elon" to "Steve".
In the example above, the direction of the friendship is from "Albert" to "Michelle".
While in most of the cases the direction is important, sometimes, like with the friendship, it doesn't really matter the direction because if A is friend with B, it's true also the opposite.

In our example, the relationship is `Elon ---Friend---> Steve`.
This means that if I want to retrieve all Elon's friends, I could start from the vertex "Elon" and traverse all the *outgoing* edges of type "IsFriendOf".
In our example, the relationship is `Albert ---Friend---> Michelle`.
This means that if I want to retrieve all Albert's friends, I could start from the vertex "Albert" and traverse all the *outgoing* edges of type "IsFriendOf".

Instead, if I want to retrieve all Steve's friends, I could start from Steve as root vertex and traverse all the **incoming** edges.
Instead, if I want to retrieve all Michelle's friends, I could start from Michelle as root vertex and traverse all the **incoming** edges.

In case the direction doesn't really matters (like with friendship), I could consider **both** outgoing and incoming.

Expand All @@ -343,26 +343,26 @@ So the basic traversal operations from one or more vertices, are:
- incoming, expressed as `IN`
- both, expressed as `BOTH`

In order to load Steve's friends, this is the example by using API:
In order to load Michelle's friends, this is the example by using API:

[source,java]
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
Vertex steve; // ALREADY LOADED VIA RID, KEYS OR SQL
Iterable<Vertex> friends = steve.getVertices(DIRECTION.IN, "IsFriendOf" );
Vertex michelle; // ALREADY LOADED VIA RID, KEYS OR SQL
Iterable<Vertex> friends = michelle.getVertices(DIRECTION.IN, "IsFriendOf" );
});
}
----

Instead, if I start from Elon's vertex, it would be:
Instead, if I start from Albert's vertex, it would be:

[source,java]
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
Vertex elon; // ALREADY LOADED VIA RID, KEYS OR SQL
Iterable<Vertex> friends = elon.getVertices(DIRECTION.OUT, "IsFriendOf");
Vertex albert; // ALREADY LOADED VIA RID, KEYS OR SQL
Iterable<Vertex> friends = albert.getVertices(DIRECTION.OUT, "IsFriendOf");
});
}
----
Expand All @@ -375,7 +375,7 @@ By using SQL, you can do the traversal by using SELECT:
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
ResultSet friends = db.query( "SQL", "SELECT expand( out('IsFriendOf') ) FROM Profile WHERE name = ? AND lastName = ?", "Steve", "Jobs" );
ResultSet friends = db.query( "SQL", "SELECT expand( out('IsFriendOf') ) FROM Profile WHERE name = ? AND lastName = ?", "Michelle", "Besso" );
});
}
----
Expand All @@ -386,7 +386,7 @@ Or with the more powerful MATCH statement:
----
try( Database db = databaseFactory.open(); ){
db.transaction( () -> {
ResultSet friends = db.query( "SQL", "MATCH {type: Profile, as: Profile, where: (name = ? and lastName = ?)}.out('IsFriendOf') {as: Friend} RETURN Friend", "Steve", "Jobs" );
ResultSet friends = db.query( "SQL", "MATCH {type: Profile, as: Profile, where: (name = ? and lastName = ?)}.out('IsFriendOf') {as: Friend} RETURN Friend", "Michelle", "Besso" );
});
}
----
Expand All @@ -397,7 +397,7 @@ Since ArcadeDB is 100% compliant with Gremlin 3.7.x, you can run this query agai

[source,gremlin]
----
g.V().has('name','Steve').has('lastName','Jobs').out('IsFriendOf');
g.V().has('name','Michelle').has('lastName','Besso').out('IsFriendOf');
----

For more information about Apache Gremlin see: <<Gremlin-API,Gremlin API>> support
Expand All @@ -410,7 +410,7 @@ The same query would be the following:
[source,cypher]
----
MATCH (me)-[:IsFriendOf]-(friend)
WHERE me.name = 'Steve' and me.lastName = 'Jobs'
WHERE me.name = 'Michelle' and me.lastName = 'Besso'
RETURN friend.name, friend.lastName
----

Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/appendix/settings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ If you're embedding a server in your Java application you can use these settings
|`server.databaseLoadAtStartup`|Open all the available databases at server startup|Boolean|true
|`server.databaseDirectory`|Directory containing the database|String|${arcadedb.server.rootPath}/databases
|`server.backupDirectory`|Directory containing the backups|String|${arcadedb.server.rootPath}/backups
|`server.defaultDatabases`|The default databases created when the server starts. The format is `(<database-name>[(<user-name>:<user-passwd>[:<user-group>])[,]*])[{import\|restore:<URL>}][;]*'. Pay attention on using `;` to separate databases and `,` to separate credentials. The supported actions are `import` and `restore`. Example: `Universe[elon:musk:admin];Amiga[Jay:Miner,Jack:Tramiel]{import:/tmp/movies.tgz}`|String|
|`server.defaultDatabases`|The default databases created when the server starts. The format is `(<database-name>[(<user-name>:<user-passwd>[:<user-group>])[,]*])[{import\|restore:<URL>}][;]*'. Pay attention on using `;` to separate databases and `,` to separate credentials. The supported actions are `import` and `restore`. Example: `Universe[albert:einstein:admin];Amiga[Jay:Miner,Jack:Tramiel]{import:/tmp/movies.tgz}`|String|
|`server.defaultDatabaseMode`|The default mode to load pre-existing databases. The value must match a com.arcadedb.engine.PaginatedFile.MODE enum value: {READ_ONLY, READ_WRITE}Databases which are newly created will always be opened READ_WRITE.|String|READ_WRITE
|`server.httpIncomingHost`|TCP/IP host name used for incoming HTTP connections|String|0.0.0.0
|`server.httpIncomingPort`|TCP/IP port number used for incoming HTTP connections. Specify a single port or a range `<from>-<to>`. Default is 2480-2489 to accept a range of ports in case they are occupied.|String|2480-2489
Expand Down
14 changes: 7 additions & 7 deletions src/main/asciidoc/server/server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ Instead of starting a server and then connect to it to create the default databa

[source,console]
----
$ bin/server.sh "-Darcadedb.server.defaultDatabases=Universe[elon:musk]"
$ bin/server.sh "-Darcadedb.server.defaultDatabases=Universe[albert:einstein]"
----

With the example above the database "Universe" will be created if doesn't exist, with user "elon", password "musk".
With the example above the database "Universe" will be created if doesn't exist, with user "albert", password "einstein".

NOTE: Due to the use of `[]`, the command line argument needs to be wrapped in quotes.

Expand Down Expand Up @@ -172,11 +172,11 @@ The default configuration is the following.
Where:

- Line 1 contains 2 loggers, the console and the file. This means logs will be written in both console (process output) and configured file (see (7))
- Line 2 sets INFO (information) as the default logging level for all the Java classes between FINER, FINE, INFO, WARNING, SEVERE
- Line 3 is as (2) but sets the level for ArcadeDB package only SEVERE
- Line 4 sets the minimum level the console logger filters the log file (below INFO level will be discarded)
- Line 5 sets the formatter used for the console. The AnsiLogFormatter supports ANSI color codes
- Line 6 sets the minimum level the file logger filters the log file (below INFO level will be discarded)
- Line 2 sets INFO (information) as the default logging level for all the Java classes between `FINER`, `FINE`, `INFO`, `WARNING`, `SEVERE`
- Line 3 is as (2) but sets the level for ArcadeDB package only `SEVERE`
- Line 4 sets the minimum level the console logger filters the log file (below `INFO` level will be discarded)
- Line 5 sets the formatter used for the console. The `AnsiLogFormatter`` supports https://en.wikipedia.org/wiki/ANSI_escape_code#Colors[ANSI color codes]
- Line 6 sets the minimum level the file logger filters the log file (below `INFO` level will be discarded)
- Line 7 sets the path where to write the log file (the file will have a counter suffix, see (10))
- Line 8 sets the formatter used for the file
- Line 9 sets the maximum file size for the log, before creating a new file. By default is 100MB
Expand Down
12 changes: 6 additions & 6 deletions src/main/asciidoc/sql/SQL-Functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ SELECT intersect(friends) FROM profile WHERE jobTitle = 'programmer'

[source,sql]
----
SELECT intersect(inEdges, outEdges) FROM OGraphVertex
SELECT intersect(inEdges, outEdges) FROM GraphVertex
----

'''
Expand Down Expand Up @@ -684,7 +684,7 @@ Syntax: `list(&lt;field|value&gt;[,]*)`

[source,sql]
----
SELECT name, list(roles.name) AS roles FROM OUser
SELECT name, list(roles.name) AS roles FROM User
----

'''
Expand Down Expand Up @@ -719,7 +719,7 @@ Syntax: `map(&lt;key&gt;,&lt;value&gt;[,]*)`

[source,sql]
----
SELECT map(name, roles.name) FROM OUser
SELECT map(name, roles.name) FROM User
----

'''
Expand Down Expand Up @@ -986,7 +986,7 @@ Syntax: `set(&lt;field|value&gt;[,]*)`

[source,sql]
----
SELECT name, set(roles.name) AS roles FROM OUser
SELECT name, set(roles.name) AS roles FROM User
----

'''
Expand Down Expand Up @@ -1154,7 +1154,7 @@ SELECT symmetricDifference(tags) FROM book

[source,sql]
----
SELECT symmetricDifference(inEdges, outEdges) FROM OGraphVertex
SELECT symmetricDifference(inEdges, outEdges) FROM GraphVertex
----

'''
Expand Down Expand Up @@ -1282,7 +1282,7 @@ SELECT unionall(friends) FROM profile

[source,sql]
----
SELECT unionall(inEdges, outEdges) FROM OGraphVertex WHERE label = 'test'
SELECT unionall(inEdges, outEdges) FROM GraphVertex WHERE label = 'test'
----

'''
Expand Down
6 changes: 3 additions & 3 deletions src/main/asciidoc/sql/SQL-Match.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ RETURN c.name
*DISTINCT*
The MATCH statement returns all the occurrences of a pattern, even if they are duplicated. To have unique, distinct records
as a result, you have to specify the DISTINCT keyword in the RETURN statement.
The `MATCH`` statement returns all the occurrences of a pattern, even if they are duplicated. To have unique, distinct records
as a result, you have to specify the `DISTINCT` keyword in the `RETURN` statement.
Example: suppose you have a dataset made like following:
Expand All @@ -319,7 +319,7 @@ Example: suppose you have a dataset made like following:
INSERT INTO V SET name = 'Jenny', surname = 'Rose'
----
This is the result of the query without a DISTINCT clause:
This is the result of the query without a `DISTINCT` clause:
[source,sql]
----
Expand Down
6 changes: 3 additions & 3 deletions src/main/asciidoc/sql/SQL-Methods.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ Applies to the following types:

[source,sql]
----
SELECT expand( @this.exclude( 'password' ) ) FROM OUser
SELECT expand( @this.exclude( 'password' ) ) FROM User
----

You can specify a wildcard as ending character to exclude all the fields that start with a certain string.
Expand Down Expand Up @@ -716,7 +716,7 @@ Applies to the following types:

[source,sql]
----
SELECT expand( @this.include('name') ) FROM OUser
SELECT expand( @this.include('name') ) FROM User
----

You can specify a wildcard as ending character to inclide all the fields that start with a certain string.
Expand Down Expand Up @@ -864,7 +864,7 @@ Applies to the following types:

[source,sql]
----
SELECT 'Hello Elon'.lastIndexOf('l')
SELECT 'Hello Albert'.lastIndexOf('l')
----

'''
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/sql/SQL-Select.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SELECT [ [DISTINCT] <Projections> ]
* *<<SQL-Projections,`Projections`>>* Indicates the data you want to extract from the query as the result-set. Note: In
ArcadeDB, this variable is optional. In the projections you can define aliases for single fields, using the `AS` keyword; in
current release aliases cannot be used in the WHERE condition, GROUP BY and ORDER BY (they will be evaluated to null)
** `DISTINCT` enforces unique proejction results.
** `DISTINCT` enforces unique projection results.
* *`FROM`* Designates the object to query. This can be a type, bucket, single <<RID,RID>>, set of <<RID,RID>> index values sorted
by ascending or descending key order.
** When querying a type, for `&lt;target&gt;` use the type name.
Expand Down
Loading
Loading