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

rank #106

Merged
merged 7 commits into from
Jul 7, 2020
Merged

rank #106

Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/manual-EN/1.overview/1.concepts/1.data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Edges are used to connect vertices. Each edge usually represents a relationship

Properties are named-value pairs within vertices and edges. In our example graph, we have used the properties `id`, `name` and `age` on **player**, `id` and `name` on **team**, and `likeness` on _**like**_ edge.

## Edge Rank

Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1.


## Schema

In **Nebula Graph**, schema refers to the definition of properties (name, type, etc.). Like `MySQL`, **Nebula Graph** is a **strong typed** database. The name and data type of the properties should be determined before the data is written.
18 changes: 9 additions & 9 deletions docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
- Each vertex can associate with multiple **tags**
- **Edge** : A Link between two vertices
- Each edge can be uniquely identified by a tuple **<src_vid, dst_vid, edge_type, rank>**
- ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge
- ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero.
- ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge.
- ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1.
- Each edge can only be of one type
- **Path** : A _non-forked_ connection with multiple vertices and edges between them
- The length of a path is the number of the edges on the path, which is one less than the number of vertices
Expand Down Expand Up @@ -159,7 +159,7 @@ The following statement inserts one or more edges

<span style="color:blue">**INSERT EDGE**</span> [<span style="color:blue">**NO OVERWRITE**</span>] <edge\_type\_name> [(<prop\_list>)] <span style="color:blue">**VALUES**</span> (<edge\_value>)+

edge\_value ::= <vertex\_id> -> <vertex\_id> [@ <weight\>] : <prop\_value\_list>
edge\_value ::= <vertex\_id> -> <vertex\_id> [@ <rank\>] : <prop\_value\_list>

#### Update a Vertex

Expand All @@ -178,7 +178,7 @@ The following statement updates a vertex

The following statement updates an edge

<span style="color:blue">**UPDATE EDGE**</span> <vertex\_id> -> <vertex\_id> [@<weight\>] <span style="color:blue">**OF**</span> <edge\_type>
<span style="color:blue">**UPDATE EDGE**</span> <vertex\_id> -> <vertex\_id> [@<rank\>] <span style="color:blue">**OF**</span> <edge\_type>
<span style="color:blue">**SET**</span> <update\_decl>
[<span style="color:blue">**WHERE**</span> <conditions\>]
[<span style="color:blue">**YIELD**</span> <field\_list>]
Expand Down Expand Up @@ -272,8 +272,8 @@ All property names start with a letter. There are a few system property names st

### Built-in Properties

\_id : Vertex id
\_type : Edge type
\_src : Source ID of the edge
\_dst : Destination ID of the edge
\_rank : Edge rank number
- \_id : Vertex id
- \_type : Edge type
- \_src : Source ID of the edge
- \_dst : Destination ID of the edge
- \_rank : Edge rank number
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ FETCH PROP ON <edge_type> <vid> -> <vid>[@<rank>] [, <vid> -> <vid> ...] [YIELD

`<vid> -> <vid>` denotes a starting vertex to (->) an ending vertex. Multiple edges are separated by comma(,).

`<rank>` specifies the edge weight of the same edge type; it's optional.
`<rank>` specifies the edge rank of the same edge type; it's optional. If not specified, the edge ranked 0 is returned by default.

`[YIELD [DISTINCT] <return_list>]` is the property list returned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ INSERT VERTEX statement inserts one vertex into **Nebula Graph**.

* `tag_name` denotes the `tag` (vertex type), which must be created before `INSERT VERTEX`.
* `prop_name_list` is the property name list in the given `tag_name`.
* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. `vid` supports specifying ID manually or using hash to generate.
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
* `prop_value_list` must provide the value list according to the `prop_name_list`. If no value matches the type, an error will be returned.

## Examples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# WHERE Syntax

Currently, the `WHERE` statement only applies to the `GO` statement.
Currently, the `WHERE` statement applies to the `GO` and `LOOKUP` statement. Note some `WHERE` filter conditions are not supported in the `LOOKUP` statement. Refer to the [LOOKUP Doc](lookup-syntax.md) for details.
The `WHERE` clause allows you to specify a search condition for the data returned by a query. The following shows the syntax of the WHERE clause:

```ngql
WHERE <expression> [ AND | OR <expression> ...])
```

Currently, the `WHERE` statement applies to the `GO` and `LOOKUP` statement. Note some `WHERE` filter conditions are not supported in the `LOOKUP` statement. Refer to the [LOOKUP Doc](lookup-syntax.md) for details.

Usually, `WHERE` is a set of logical combination that filters vertex or edge properties.

> As syntactic sugar, logic AND is represented by `AND` or `&&` and logic OR is represented by `OR` or `||`.
Expand Down Expand Up @@ -54,3 +55,35 @@ nebula> GO FROM 101 OVER follow WHERE 1 == 1 OR TRUE;
| 102 |
---------------
```

## Filtering Edge Rank with WHERE

You can filter the edge rank with the `WHERE` clause. For example:

```ngql
nebula> CREATE SPACE test;
nebula> USE test;
nebula> CREATE EDGE e1(p1 int);
nebula> CREATE TAG person(p1 int);
nebula> INSERT VERTEX person(p1) VALUES 1:(1);
nebula> INSERT VERTEX person(p1) VALUES 2:(2);
nebula> INSERT EDGE e1(p1) VALUES 1->2@0(10);
nebula> INSERT EDGE e1(p1) VALUES 1->2@1(11);
nebula> INSERT EDGE e1(p1) VALUES 1->2@2(12);
nebula> INSERT EDGE e1(p1) VALUES 1->2@3(13);
nebula> INSERT EDGE e1(p1) VALUES 1->2@4(14);
nebula> INSERT EDGE e1(p1) VALUES 1->2@5(15);
nebula> INSERT EDGE e1(p1) VALUES 1->2@6(16);
nebula> GO FROM 1 OVER e1 WHERE e1._rank>2 YIELD e1._src, e1._dst, e1._rank AS Rank, e1.p1 | ORDER BY Rank DESC;
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
====================================
| e1._src | e1._dst | Rank | e1.p1 |
====================================
| 1 | 2 | 6 | 16 |
------------------------------------
| 1 | 2 | 5 | 15 |
------------------------------------
| 1 | 2 | 4 | 14 |
------------------------------------
| 1 | 2 | 3 | 13 |
------------------------------------
```