diff --git a/docs/cn_manual_doc/Data_Types/Nemeric_Types.md b/docs/cn_manual_doc/Data_Types/Nemeric_Types.md new file mode 100755 index 00000000000..40a0bcc4186 --- /dev/null +++ b/docs/cn_manual_doc/Data_Types/Nemeric_Types.md @@ -0,0 +1,7 @@ +# 数类 + +Nebula支持两种基础数据类型 -- int64 & double + +int64的范围是[-9223372036854775808, 9223372036854775807]。double没有上限和下限。 + +注意:在基于int64的计算中不存在溢出。 \ No newline at end of file diff --git a/docs/cn_manual_doc/Data_Types/String_Types.md b/docs/cn_manual_doc/Data_Types/String_Types.md new file mode 100755 index 00000000000..3baa78aaaac --- /dev/null +++ b/docs/cn_manual_doc/Data_Types/String_Types.md @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/docs/cn_manual_doc/Functions_and_Operators/Comparison_Functions_and_Operators.md b/docs/cn_manual_doc/Functions_and_Operators/Comparison_Functions_and_Operators.md new file mode 100755 index 00000000000..b78a4ed644f --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Comparison_Functions_and_Operators.md @@ -0,0 +1,103 @@ +# 比较函数和运算符 + +| 运算符 | 描述 | +|:---- |:----:| +| = | 赋值运算符 | +| / | 除法运算符 | +| == | 等于运算符 | +| != | 不等于运算符 | +| < | 小于运算符 | +| <= | 小于或等于运算符 | +| - | 减法运算符 | +| % | 余数运算符 | +| + | 加法运算符 | +| * | 乘法运算符 | +| - | 负号运算符 | + + +比较运算的结果是 _true_ 或 _false_ 。 + +* == + +等于。String的比较大小写敏感。不同类的值不相同: + +``` +nebula> YIELD 'A' == 'a'; +============== +| ("A"=="a") | +============== +| false | +-------------- + +nebula> YIELD '2' == 2; +============ +| ("2"==2) | +============ +|false | +------------ +``` + +* > + +大于: + +``` +nebula> YIELD 3 > 2; +========= +| (3>2) | +========= +| true | +--------- +``` + +* ≥ + +大于或等于: + +``` +nebula> YIELD 2 >= 2; +========== +| (2>=2) | +========== +| true | +---------- +``` + +* < + +小于: + +``` +nebula> YIELD 2.0 < 1.9; +======================= +| (2.000000<1.900000) | +======================= +| false | +----------------------- +``` + +* ≤ + +小于或等于: + +``` +nebula> YIELD 0.11 <= 0.11; +======================== +| (0.110000<=0.110000) | +======================== +| true | +------------------------ +``` + +* != + +不等于: + +``` +nebula> YIELD 1 != '1' +============ +| (1!="1") | +============ +| true | +------------ +``` \ No newline at end of file diff --git a/docs/cn_manual_doc/Functions_and_Operators/Functions_and_Operator_Reference.md b/docs/cn_manual_doc/Functions_and_Operators/Functions_and_Operator_Reference.md new file mode 100755 index 00000000000..e66b52acdca --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Functions_and_Operator_Reference.md @@ -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() | 返回正切函数值 | diff --git a/docs/cn_manual_doc/Functions_and_Operators/Group_By_Function.md b/docs/cn_manual_doc/Functions_and_Operators/Group_By_Function.md new file mode 100755 index 00000000000..c6070956968 --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Group_By_Function.md @@ -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的总合。 +``` \ No newline at end of file diff --git a/docs/cn_manual_doc/Functions_and_Operators/Logical_Operators.md b/docs/cn_manual_doc/Functions_and_Operators/Logical_Operators.md new file mode 100755 index 00000000000..ed71d3ba77d --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Logical_Operators.md @@ -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 | +``` \ No newline at end of file diff --git a/docs/cn_manual_doc/Functions_and_Operators/Operator_Precedence.md b/docs/cn_manual_doc/Functions_and_Operators/Operator_Precedence.md new file mode 100755 index 00000000000..ae0de1f7d55 --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Operator_Precedence.md @@ -0,0 +1,23 @@ +# 运算符优先级 + +下面的列表展示了 nGQL 运算符的优先级(降序)。同一行的运算符拥有一致的优先级。 +``` +! +- (unary minus) +*, /, % +-, + +== , >=, >, <=, <, <>, != +&& +|| += (assignment) +``` + +在一个表达式中,同等优先级的运算符将按照从左到右的顺序执行,唯一例外是赋值按照从右往左的顺序执行。但是,可以使用括号来修改执行顺序。 + +示例: + +``` +nebula> YIELD 2+3*5; +nebula> YIELD (2+3)*5; +``` + diff --git a/docs/cn_manual_doc/Functions_and_Operators/Order_By_Function.md b/docs/cn_manual_doc/Functions_and_Operators/Order_By_Function.md new file mode 100755 index 00000000000..4f7dee24ebc --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Order_By_Function.md @@ -0,0 +1,33 @@ +# Order By 函数 + +类似于 SQL, `ORDER BY` 可以进行升序 (`ASC`) 或降序 (`DESC`) 的排序来返回结果. +并且它只能在`PIPE`语句 ("|") 中使用 + +``` +ORDER BY ASC | DESC [, 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 | + ========================== + 第一列按升序排列,第二列按降序排列,第三列按升序排列 +``` diff --git a/docs/cn_manual_doc/Functions_and_Operators/Set_Operation.md b/docs/cn_manual_doc/Functions_and_Operators/Set_Operation.md new file mode 100755 index 00000000000..e69de29bb2d diff --git a/docs/cn_manual_doc/Functions_and_Operators/Type_Conversion.md b/docs/cn_manual_doc/Functions_and_Operators/Type_Conversion.md new file mode 100755 index 00000000000..c426d9bb6b8 --- /dev/null +++ b/docs/cn_manual_doc/Functions_and_Operators/Type_Conversion.md @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/docs/cn_manual_doc/Language_Structure/Literal_Values/Boolean_Literals.md b/docs/cn_manual_doc/Language_Structure/Literal_Values/Boolean_Literals.md new file mode 100644 index 00000000000..245f93d49eb --- /dev/null +++ b/docs/cn_manual_doc/Language_Structure/Literal_Values/Boolean_Literals.md @@ -0,0 +1,10 @@ +# 布尔字面值 + +布尔字面值 `TRUE` 和 `FALSE` 对大小写不敏感。 + +``` +nebula> yield TRUE, true, FALSE, false, FalsE +========================================= +|  true |  true | false | false | false |   +========================================= +``` diff --git a/docs/cn_manual_doc/Language_Structure/Literal_Values/NULL_Values.md b/docs/cn_manual_doc/Language_Structure/Literal_Values/NULL_Values.md new file mode 100644 index 00000000000..5695f76a65d --- /dev/null +++ b/docs/cn_manual_doc/Language_Structure/Literal_Values/NULL_Values.md @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/docs/cn_manual_doc/Language_Structure/Literal_Values/Numeric_Literals.md b/docs/cn_manual_doc/Language_Structure/Literal_Values/Numeric_Literals.md new file mode 100644 index 00000000000..7d8a9bf79a3 --- /dev/null +++ b/docs/cn_manual_doc/Language_Structure/Literal_Values/Numeric_Literals.md @@ -0,0 +1,20 @@ +# 数值字面值 + +数值字面值包括整数字面值和浮点字面值。 + +整数为64位,并且可以用 `+` 和 `-` 来表明正负性。它们和 C 语言中的 `int64_t` 是一致的。 + +浮点数和 C 语言中的 `double` 是一致的。 + +以下为几个例子: + +``` +1, -5, +10000100000 +-2.3, +1.00000000000 +``` + +注意整数的最大值为 `9223372036854775807`。输入任何大于此最大值的整数为语法错误。整数的最小值`-9223372036854775808` 同理。 + +然而浮点数没有上限和下限。 + +科学计数法会在下个 release 版本中支持。 \ No newline at end of file diff --git a/docs/cn_manual_doc/Language_Structure/Literal_Values/String_Literals.md b/docs/cn_manual_doc/Language_Structure/Literal_Values/String_Literals.md new file mode 100644 index 00000000000..6fb5e7e3807 --- /dev/null +++ b/docs/cn_manual_doc/Language_Structure/Literal_Values/String_Literals.md @@ -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 |  +-------------------- + + +``` + diff --git a/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/DESCRIBE_syntax.md b/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/DESCRIBE_syntax.md new file mode 100644 index 00000000000..85fc917de17 --- /dev/null +++ b/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/DESCRIBE_syntax.md @@ -0,0 +1,50 @@ +# DESCRIBE + +``` +DESCRIBE SPACE space_name +DESCRIBE TAG tag_name +DESCRIBE EDGE edge_name +``` + +在 Nebula 中 DESCRIBE 和 EXPLAIN 是`不同`的关键词。 DESCRIBE 关键词的作用是获取关于 space, tag, edge 结构的信息。 然而 EXPLAIN 的作用是查看nGQL语句的执行计划。( EXPLAIN 将在下个版本中发布)。 + +同时需要注意的是,DESCRIBE 和 SHOW 也是不同的。 详细参见 SHOW 文档。 + +### 示例 + +获取指定 space 的信息,对应 ` DESCRIBE SPACE `。 + +``` +nebula> DESCRIBE SPACE laura_space; +======================================================== +| ID |        Name | Partition number | Replica Factor | +======================================================== +|  1 | laura_space |             1024 |              1 | +--------------------------------------------------------  +``` + +获取指定 tag 的信息,对应 ` DESCRIBE TAG `。 + +``` +nebula> DESCRIBE TAG player +================== +| Field |   Type | +================== +|  name | string | +------------------ +|   age |    int | +------------------  +``` + +获取指定 EDGE 的信息,对应 ` DESCRIBE EDGE `。 + +``` +nebula> DESCRIBE EDGE serve +===================== +|      Field | Type | +===================== +| start_year |  int | +--------------------- +|   end_year |  int | +--------------------- +``` diff --git a/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/USE_syntax.md b/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/USE_syntax.md new file mode 100644 index 00000000000..5108bef0dd2 --- /dev/null +++ b/docs/cn_manual_doc/Statement_Syntax/Utility_Statements/USE_syntax.md @@ -0,0 +1,22 @@ +# USE + +``` +USE graph_space_name +``` + +在 Nebula 中 `USE` 语句的作用是选择一个图空间来作为当前的工作图空间。USE 需要一些特定的权限来执行。 + +当前的图空间会保持默认直至当前会话结束或另一个 USE 被执行。 + +``` +USE space1 +GO FROM 1 OVER edge1 -- 遍历 space1 +USE space2 +GO FROM 1 OVER edge1 -- 遍历 space2。所有的 nodes 和 edges 与 space1 无关. +USE space1; -- 此时你回到了 space1。 至此你不能从 space2 中读取数据。 +``` + +和 SQL 不同的是,选取一个当前的工作图空间会阻止你访问其他图空间。遍历一个新的图空间的唯一方案是通过 `USE` 语句来切换工作图空间 + +> SPACES 之间是 `完全隔离的`。不像 SQL 允许在一个语句中选择两个来自不同数据库的表单,在 Nebula 中一时间只能对一个图空间进行操作。 + diff --git a/docs/manual-doc/language-structure/literal-values/string-literals.md b/docs/manual-doc/language-structure/literal-values/string-literals.md index 15f62538fc0..1786b661b6a 100644 --- a/docs/manual-doc/language-structure/literal-values/string-literals.md +++ b/docs/manual-doc/language-structure/literal-values/string-literals.md @@ -5,15 +5,15 @@ nebula> YIELD 'a string' nebula> YIELD "another string" ``` -Certain backslash escapes (\) have been supported (also known as the *escape character*). They are shown in the following table: +Certain backslash escapes (\\) have been supported (also known as the *escape character*). They are shown in the following table: | **Escape Sequence** | **Character Represented by Sequence** | |:----|:----| | \' | A single quote (') character | | \" | A double quote (") character | -| \t | A tab character | -| \n | A newline character | -| \b | A backspace character | -| \\ | A backslash (\) character | +| \t | A tab character | +| \n | A newline character | +| \b | A backspace character | +| \\| | A backslash (\\) character | Here are some examples: