PGX supports the following primitive data types.
integer
, long
, float
, and double
. These types have the same size, range and
precision of the corresponding Java primitive data type.boolean
data type has only two possible values: true and false. As with Java and C++,
its size is not precisely defined.String
is a primitive data type in PGX. PGX follows the Java conventions for String representation.date
, time
, timestamp
, time with time zone
, and timestamp with time zone
. These types
correspond to the Java types LocalDate
, LocalTime
, LocalDateTime
, OffsetTime
, OffsetDateTime
from the
standard library package java.util.time
.vertex
or edge
of the graph itself is a proper type in PGX.An overview of the different data types and their integration in different languages and APIs is as follows:
data type | loading & storing | PGX Java API | PGQL and Filter Expression | Green-Marl |
---|---|---|---|---|
string | string | String | STRING | string |
int / integer | int / integer | int | INT / INTEGER | int |
long | long | long | LONG | long |
float | float | float | FLOAT | float |
double | double | double | DOUBLE | double |
boolean | boolean | boolean | BOOLEAN | bool |
date | local_date | LocalDate | DATE | - |
time | time | LocalTime | TIME | - |
timestamp | timestamp | LocalDateTime | TIMESTAMP | - |
time with time zone | time_with_timezone | OffsetTime | TIME WITH TIME ZONE | - |
timestamp with time zone | timestamp_with_timezone | OffsetDateTime | TIMESTAMP WITH TIME ZONE | - |
vertex | - | PgxVertex | - | node |
edge | - | PgxEdge | - | edge |
All properties and scalar variables should be one of the above primitive data types.
Note that vertex
(and edge
) is itself a valid primitive data type. For
instance, in a path-finding algorithm, each vertex can have a temporary property
predecessor
that stores which incoming neighbor is the predecessor vertex in
the path. Such a property would have the type vertex
.
Also note that in the graph config, local_date
should be used instead of date
.
To see examples of usage of datetime data types, see Using Datetime Data Types.
The following table summarizes the minimum and maximum values for each data type. Note that for float and double types, the smallest absolute value is included in the table, the minimum value is the negative of maximum value for these types.
data type | min value | max value |
---|---|---|
int / integer | -2147483648 | 2147483647 |
long | -9223372036854775808 | 9223372036854775807 |
float | 1.4E-45 | 3.4028235e+38 |
double | 4.9E-324 | 1.7976931348623157E308 |
date | -5877641-06-23 | 5881580-07-11 |
time | 00:00:00.000 | 23:59:59.999 |
timestamp | -292275055-05-17 00:00:00.000 | 292278994-08-17 07:12:55.807 |
time with time zone | 00:00:00.000+18:00 | 23:59:59.999-18:00 |
timestamp with time zone | -292275055-05-17 00:00:00.000+18:00 | 292278994-08-17 07:12:55.807-18:00 |
For string values, PGX supports arbitrary long strings.
PGX supports three different collection types: sequence
, set
and order
.
All of these collections can contain values of the vertex
type, but each has different semantics regarding uniqueness and preserving the order of its elements:
Sequence: a sequence
works basically like a list. It preserves the order of the elements added to it, and the same element can appear multiple times.
Set: a set
can contain the same value once at the most. Adding a value that is already in the set
will have no effect. set
does not preserve the order of the elements it contains.
Order: just like the set
, the order
collection will contain each element once at the most. But the order
preserves the order of the elements inserted into it; i.e., it is a FIFO data structure.
To see examples of creation and usage of the different collections, see Using Collections.
Some operations, like PgxGraph.getVertices()
and PgxGraph.getEdges()
return immutable collections.
These collections behave like normal collections, but cannot be modified by operations like addAll
or removeAll
and clear
.
An immutable collection can be transformed into a mutable collection by using the toMutable
method, which returns a mutable copy of the collection.
If toMutable
is called on a collection that is already mutable, the method has the same result as the method clone
.
To check if a collection is mutable, the isMutable
method can be used.
PGX provides two different kinds of maps:
PropertyType
. This is the kind of maps to use if the key or value
types are graph-related like VERTEX
and EDGE
otherwise using session-bound maps is recommended.To see examples of creation and usage of maps, see Using Maps.