Vector types¶
The vector type is a data type used to describe vector data, which is defined by a fixed number of dimensions and a specific data type of the coordinates.
Syntax¶
- vector
vector ::=
'VECTOR' '<' dimension ',' coordinate_type '>'
Each vector type is declared with the keyword VECTOR followed by the number of dimensions and the data type of the coordinates. The number of dimensions must be within the range of 1 to 2,147,483,647. As for the data type of the coordinates, only FLOAT is supported currently.
Declaration example¶
'''
CREATE GRAPH TYPE IF NOT EXISTS person AS
{ NODE Person
( {
id INT64 PRIMARY KEY,
is_adult BOOL DEFAULT TRUE,
slogan VECTOR<3, FLOAT> DEFAULT NULL,
selfintro VECTOR<10, FLOAT> NULL
} )
}
'''
Note
- Only the
NULLvalue can be assigned as the default value of aVECTORproperty. VECTORproperties CANNOT be used to form the primary key of a node type or the multi-edge key of an edge type. For more information, see primary_key_list and multi_edge_key_list.
Supported arithmetic operations¶
The following table lists the arithmetic operations that can be performed on vector type values. For detailed example, see Arithmetic operations for vectors.
| Operand 1 | Operator | Operand 2 | Result |
|---|---|---|---|
| vector | + or - |
number or vector with the same dimension | vector |
| vector | * or / |
number | vector |