Skip to content

Commit

Permalink
Translate manual docs into CN (Partial). (#791)
Browse files Browse the repository at this point in the history
* Translate manual docs into CN (Partial).

* Resolve translation problems

* Resolve translation problems 2

* Resolve translation problems & add translation for Literals

* Resolve translation problems 3
  • Loading branch information
boyuanfang authored and dangleptr committed Aug 19, 2019
1 parent beaf190 commit 80c3cef
Show file tree
Hide file tree
Showing 17 changed files with 423 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docs/cn_manual_doc/Data_Types/Nemeric_Types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 数类

Nebula支持两种基础数据类型 -- int64 & double

int64的范围是[-9223372036854775808, 9223372036854775807]。double没有上限和下限。

注意:在基于int64的计算中不存在溢出。
3 changes: 3 additions & 0 deletions docs/cn_manual_doc/Data_Types/String_Types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!---
String 是动态长度字符串,没有最长长度限制。
--->
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 比较函数和运算符

| 运算符 | 描述 |
|:---- |:----:|
| = | 赋值运算符 |
| / | 除法运算符 |
| == | 等于运算符 |
| != | 不等于运算符 |
| < | 小于运算符 |
| <= | 小于或等于运算符 |
| - | 减法运算符 |
| % | 余数运算符 |
| + | 加法运算符 |
| * | 乘法运算符 |
| - | 负号运算符 |


比较运算的结果是 _true__false_

* ==

等于。String的比较大小写敏感。不同类的值不相同:

```
nebula> YIELD 'A' == 'a';
==============
| ("A"=="a") |
==============
| false |
--------------
nebula> YIELD '2' == 2;
============
| ("2"==2) |
============
|false |
------------
```

* &gt;

大于:

```
nebula> YIELD 3 > 2;
=========
| (3>2) |
=========
| true |
---------
```

* &ge;

大于或等于:

```
nebula> YIELD 2 >= 2;
==========
| (2>=2) |
==========
| true |
----------
```

* &lt;

小于:

```
nebula> YIELD 2.0 < 1.9;
=======================
| (2.000000<1.900000) |
=======================
| false |
-----------------------
```

* &le;

小于或等于:

```
nebula> YIELD 0.11 <= 0.11;
========================
| (0.110000<=0.110000) |
========================
| true |
------------------------
```

* !=

不等于:

```
nebula> YIELD 1 != '1'
============
| (1!="1") |
============
| true |
------------
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 函数和运算符

| ***名称*** | ***描述*** |
|:----|:----:|
| abs() | 返回绝对值 |
| acos() | 返回反余弦函数值 |
| asin() | 返回反正弦函数值 |
| atan() | 返回反正切函数值 |
| cbrt() | 返回参数的三次方根 |
| ceil() | 返回大于参数的最小整数(向上取整) |
| cos() | 返回余弦函数值 |
| exp() | 增加到自然指数的指定次幂 |
| floor() | 返回小于参数的最大整数(向下取整) |
| hypot() | 返回一个正三角形的斜边 |
| log() | 返回第一个参数的自然对数 |
| log2() | 返回第一个参数底数为2的对数 |
| log10() | 返回第一个参数底数为10的对数 |
| now() | 返回当前日期和时间 |
| pow() | 返回将参数增加到指定次幂 |
| rand32() | 返回一个随机的32位整数 |
| rand64() | 返回一个随机的64位整数 |
| round() | 对参数取整 |
| sin() | 返回正弦函数值 |
| sqrt() | 返回参数的平方根 |
| strcasecmp() | 无视大小写比较字符串 |
| tan() | 返回正切函数值 |
26 changes: 26 additions & 0 deletions docs/cn_manual_doc/Functions_and_Operators/Group_By_Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# 聚合函数 (Group by)

`GROUP BY` 函数类似于SQL。 只能在 `YIELD` 语句中使用.

|名称 | 描述 |
|:----|:----:|
| AVG() | 返回参数的平均值 |
| COUNT() | 返回记录值总数 |
| COUNT(DISTINCT) | 返回独立记录值的总数 |
| MAX() | 返回最大值 |
| MIN() | 返回最小值 |
| STD() | 返回总体标准差 |
| SUM() | 返回总合 |

以上函数只作用于 int64 和 double。

### 示例

```
nebula> GO FROM 1 OVER e1 | YIELD $-.id AS fid, COUNT(*) AS cnt GROUP BY fid
-- 统计与节点"1" 有e1关系的点的id出现的次数
nebula> GO FROM 1 YIELD e1._dst AS fid, e1.prop1 AS prop1 | YIELD fid, SUM(prop1) GROUP BY fid
-- 统计与节点"1" 有e1关系的点的prop1的总合。
```
49 changes: 49 additions & 0 deletions docs/cn_manual_doc/Functions_and_Operators/Logical_Operators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 逻辑运算符

| ***名称*** | ***描述*** |
|:----|:----:|
| && | 逻辑和 AND |
| ! | 逻辑非 NOT |
| \|\| | 逻辑或 OR |


在 nGQL 中, 非 0 数字将被视为 _true_. 逻辑运算符的优先级参见 [Operator Precedence](./Operator_Precedence.md)

* &&

逻辑和 AND:

```
nebula> YIELD -1 && true;
================
| (-(1)&&true) |
================
| true |
----------------
```

* !

逻辑非 NOT:

```
nebula> YIELD !(-1);
===========
| !(-(1)) |
===========
| false |
-----------
```

* ||

逻辑或 OR:

```
nebula> YIELD 1 || !1;
=============
| (1||!(1)) |
=============
| true |
```
23 changes: 23 additions & 0 deletions docs/cn_manual_doc/Functions_and_Operators/Operator_Precedence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 运算符优先级

下面的列表展示了 nGQL 运算符的优先级(降序)。同一行的运算符拥有一致的优先级。
```
!
- (unary minus)
*, /, %
-, +
== , >=, >, <=, <, <>, !=
&&
||
= (assignment)
```

在一个表达式中,同等优先级的运算符将按照从左到右的顺序执行,唯一例外是赋值按照从右往左的顺序执行。但是,可以使用括号来修改执行顺序。

示例:

```
nebula> YIELD 2+3*5;
nebula> YIELD (2+3)*5;
```

33 changes: 33 additions & 0 deletions docs/cn_manual_doc/Functions_and_Operators/Order_By_Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Order By 函数

类似于 SQL, `ORDER BY` 可以进行升序 (`ASC`) 或降序 (`DESC`) 的排序来返回结果.
并且它只能在`PIPE`语句 ("|") 中使用

```
ORDER BY <prop> ASC | DESC [, <prop> ASC | DESC ...]
```
如果没有指明 ASC 或 DESC,`ORDER BY` 将默认进行升序排序。

### 示例

```
nebula> FETCH PROP ON player 1,2,3,4 YIELD player.age AS age, player.weight AS weight | ORDER BY $-.age, $-.weight DESC
-- 取4个顶点并将他们以age从小到大的顺序排列,如 age 一致,则按 weight 从大到小的顺序排列。
```
(参见 `FETCH` 文档来了解使用方法)

```
nebula> GO FROM 1 OVER edge2 YIELD $^.t1.prop1 AS s1_p1, edge2.prop2 AS e2_p2, $$.t3.prop3 AS d3_p3 | ORDER BY s1_p1 ASC, e2_p2 DESC, d3_p3 ASC
-- 返回类似如下的列表
==========================
| s1_p1 | e2_p2 | d3_p3 |
--------------------------
| 123 | 345 | 234 |
| 234 | 32 | 0 |
| 234 | 31 | 0 |
| 234 | 31 | 1 |
==========================
第一列按升序排列,第二列按降序排列,第三列按升序排列
```
Empty file.
3 changes: 3 additions & 0 deletions docs/cn_manual_doc/Functions_and_Operators/Type_Conversion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!---
Not supported yet
--->
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 布尔字面值

布尔字面值 `TRUE``FALSE` 对大小写不敏感。

```
nebula> yield TRUE, true, FALSE, false, FalsE
=========================================
|  true |  true | false | false | false |  
=========================================
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!---
> *注意* NULL 和 NOT NULL 还没有完全被支持。
`NULL` 值表示 “no data”。`NULL` 字面值对大小写不敏感. 注意 `NULL` 和 `0` 以及 空字符串的不同。
--->
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 数值字面值

数值字面值包括整数字面值和浮点字面值。

整数为64位,并且可以用 `+``-` 来表明正负性。它们和 C 语言中的 `int64_t` 是一致的。

浮点数和 C 语言中的 `double` 是一致的。

以下为几个例子:

```
1, -5, +10000100000
-2.3, +1.00000000000
```

注意整数的最大值为 `9223372036854775807`。输入任何大于此最大值的整数为语法错误。整数的最小值`-9223372036854775808` 同理。

然而浮点数没有上限和下限。

科学计数法会在下个 release 版本中支持。
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 字符串字面值

字符串由一串字节或字符组成,并由一对单引号 (') 或双引号 (") 包装。

```
nebula> YIELD 'a string'
nebula> YIELD "another string"
```

一些转义字符 (\\) 已被支持,如下表所示:
| **转移字符** | **对应的字符** |
|:----|:----|
| \' | 单引号 (') |
| \" | 双引号 (") |
| \t | 制表符 |
| \n | 换行符 |
| \b | 退格符 |
| \\\ | 反斜杠 (\\) |

示例:

```
nebula> YIELD 'This\nIs\nFour\nLines'
--------------------
| This
Is
Four
Lines |
--------------------
nebula> YIELD 'disappearing\ backslash'  
--------------------
|   disappearing backslash | 
--------------------
```

Loading

0 comments on commit 80c3cef

Please sign in to comment.