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

vid-par #68

Merged
merged 7 commits into from
Aug 11, 2020
Merged
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
14 changes: 8 additions & 6 deletions docs/manual-CN/1.overview/1.concepts/1.data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,35 @@ G = < V, E, P<sub>V</sub>, P<sub>E</sub> >,
上图为 NBA 球员及球队信息数据,图中包含 2 种类型的 11 个节点,即 player 和 team,2 种类型的边,即 serve 和 like。
以下为示例图数据涉及到的概念介绍。

## 节点
## 节点(Vertex)

节点用于表示现实世界中的实体,本例的数据中共包含 11 个节点。
节点用于表示现实世界中的实体。在 **Nebula Graph** 中,节点必须拥有唯一的标识符(即 `VID`)。在每个图空间中的 `VID` 必须是唯一的。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

本例的数据中共包含 11 个节点。

<img src="https://user-images.githubusercontent.com/42762957/64932628-00eecf00-d873-11e9-844b-6b2a535ca734.png" width="15%" height="20%">

## 标签
## 标签(Tag)

**Nebula Graph** 使用**标签**对节点进行分类,本例包含的节点标签为 **player** 和 **team**。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

<img src="https://user-images.githubusercontent.com/42762957/64932330-bff5bb00-d870-11e9-9940-4ff76ceca353.png" width="50%" height="25%">

## 边
## 边(Edge)

边用来连接节点,边通常表示两个节点间的某种关系或行为,本例中的边为 _**serve**_ 和 _**like**_。

<img src="https://user-images.githubusercontent.com/42762957/64932285-68efe600-d870-11e9-8dc7-051f7b43c4aa.png" width="50%" height="25%">

## 边类型
## 边类型(Edge Type)

每条边都有一种边类型,以边 _**serve**_ 为例,节点 `101`(表示一名球员)为起始点,节点 `215`(表示一支球队)为目标点。节点 `101` 有一条出边,而节点 `215` 有一条入边。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

## 边 rank
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

边 rank 是用户分配的不可变的 64 位带符号整数,决定两个顶点之间相同类型的边顺序。等级值较高的边排名靠前。如未指定,则默认等级值为零。目前的排序依据为“二进制编码顺序“:即 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1。

## 属性
## 属性(Property)
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

属性为点和边内部的键值对。本例中,节点 **player** 拥有属性 `id`, `name` 和 `age`,边 **like** 则拥有属性 `likeness`。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FETCH PROP ON * <vertex_id_list>

`*` 返回指定 ID 点的所有属性。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

`<tag_name>::=[tag_name [, tag_name]]` 为标签名称,与 return_list 中的标签相同。
`<tag_name_list>::=[tag_name [, tag_name]]` 为标签名称,与 return_list 中的标签相同。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

`<vertex_id_list>::=[vertex_id [, vertex_id]]` 是一组用 "," 分隔开的顶点 ID 列表。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```ngql
INSERT VERTEX <tag_name> [, <tag_name>, ...] (prop_name_list[, prop_name_list])
{VALUES | VALUE} vid: (prop_value_list[, prop_value_list])
{VALUES | VALUE} VID: (prop_value_list[, prop_value_list])

prop_name_list:
[prop_name [, prop_name] ...]
Expand All @@ -15,7 +15,7 @@ INSERT VERTEX 可向 **Nebula Graph** 插入节点。

- `tag_name` 表示标签(节点类型),在进行 `INSERT VERTEX` 操作前需创建好。
- `prop_name_list` 指定标签的属性列表。
- `vid` 表示点 ID目前的排序依据为“二进制编码顺序“:即 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1。`vid` 支持手动指定 ID 或使用 hash 生成。
- `VID` 表示点 ID。每个图空间中的 `VID` 必须是唯一的。目前的排序依据为“二进制编码顺序“:即 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1。`VID` 支持手动指定 ID 或使用 hash 生成。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
- `prop_value_list` 须根据 `prop_name_list` 列出属性,如无匹配类型,则返回错误。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

## 示例
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ $ sudo make install
$ cd /usr/local/nebula
$ cp etc/nebula-storaged.conf.production etc/nebula-storaged.conf
$ cp etc/nebula-metad.conf.production etc/nebula-metad.conf
$ cp etc/nebula-metad.conf.production etc/nebula-metad.conf
$ sudo cp etc/nebula-graphd.conf.production etc/nebula-graphd.conf
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
# 用于试用
$ cd /usr/local/nebula
$ sudo cp etc/nebula-storaged.conf.default etc/nebula-storaged.conf
$ sudo cp etc/nebula-metad.conf.default etc/nebula-metad.conf
$ sudo cp etc/nebula-metad.conf.default etc/nebula-metad.conf
$ sudo cp etc/nebula-graphd.conf.default etc/nebula-graphd.conf
```

详情参考[启动和停止 Nebula Graph 服务文档](../2.install/2.start-stop-service.md)
Expand Down
25 changes: 25 additions & 0 deletions docs/manual-CN/5.appendix/vid-partition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 节点标识符和分区

本文档提供有关节点标识符(简称 `VID`)和分区的一些介绍。

在 **Nebula Graph** 中,节点是用节点标识符(即 `VID`)标识的。插入节点时,必须指定 `VID`(int64)。`VID` 可以由应用程序生成,也可以使用 **Nebula Graph** 提供的哈希函数生成。

`VID` 在一个图空间中必须唯一。即在同一个图空间中,拥有相同 `VID` 的节点被当做同一个节点。不同图空间中的 `VID` 彼此独立。此外,一个 `VID` 可以拥有多种 `TAG`。

向 **Nebula Graph** 群集中插入数据时,节点和边会分布到不同的分区中,而这些分区又分布在多台机器上。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

`VID` 和分区的对应关系为:
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

```text
VID mod partition_number = partition ID
```

其中,

- `mod` 是取模操作。
- `partition_number` 是 `VID` 所处图空间的的分区数量即 [CREATE SPACE](../2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md) 语句中 `partition_num` 的值。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
- `partition ID` 即该 `VID` 所在分区的 `ID`。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

因此应用程序如果希望将某些节点落在同一个分区中(也即在同一台机器上),可根据上述公式自行控制 `VID` 的生成。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

此外,`partition ID` 和机器之间的对应关系是随机的。因此不可以假设任何两个分区分布在同一台机器上。
2 changes: 1 addition & 1 deletion docs/manual-CN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
* [Gremlin V.S. nGQL](5.appendix/gremlin-ngql.md)
* [Cypher V.S. nGQL](5.appendix/cypher-ngql.md)
* [SQL V.S. nGQL](5.appendix/sql-ngql.md)
<!-- * [升级 Nebula Graph](5.appendix/upgrade-guide.md) -->
* [节点标识符和分区](5.appendix/vid-partition.md)

## 其他

Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ nav:
- Cypher & nGQL: manual-CN/5.appendix/cypher-ngql.md
- Gremlin & nGQL: manual-CN/5.appendix/gremlin-ngql.md
- SQL & nGQL: manual-CN/5.appendix/sql-ngql.md
#- 升级 Nebula Graph: manual-CN/5.appendix/upgrade-guide.md
- 节点标识符和分区: manual-CN/5.appendix/vid-partition.md


- English:
- https://docs.nebula-graph.io/
Expand Down