15.6.2 Managing Collections and Scalars
The client can create graph-bound vertex and edge collections to use during the analysis with the following methods in PgxGraph
:
PgxFuture<VertexSequence<E>> createVertexSequenceAsync()
PgxFuture<VertexSequence<E>> createVertexSequenceAsync(String name)
PgxFuture<VertexSet<E>> createVertexSetAsync()
PgxFuture<VertexSet<E>> createVertexSetAsync(String name)
PgxFuture<EdgeSequence> createEdgeSequenceAsync()
PgxFuture<EdgeSequence> createEdgeSequenceAsync(String name)
PgxFuture<EdgeSet> createEdgeSetAsync()
PgxFuture<EdgeSet> createEdgeSetAsync(String name)
PGX also supports scalar collections such as set
and sequence
. Each of these collections can hold elements of various primitive data types like INTEGER
, LONG
, FLOAT
, DOUBLE
or BOOLEAN
. Scalar collections are session-bound and can be created with the following methods in PgxSession
:
PgxFuture<ScalarSet<T>> createSetAsync(PropertyType contentType, String name)
PgxFuture<ScalarSequence<T>> createSequenceAsync(PropertyType contentType, String name)
PgxFuture<ScalarSet<T>> createSetAsync(PropertyType contentType)
PgxFuture<ScalarSequence<T>> createSequenceAsync(PropertyType contentType)
In the preceding code, the optional argument (name
) specifies the name of the newly created collection. If omitted, PGX chooses a name for the client. As with properties, the collections holding vertices are parametrized with the ID
type of the vertices. Refer to graph configuration chapter to learn how to specify the vertex ID type of a graph.
The return value is the collection object which points to the newly created empty collection.
To drop a collection from the session, call destroyAsync()
(or destroy()
) on the collection object.
To check which collections are currently allocated for a graph you can use the following method:
PgxFuture<Map<String, PgxCollection<? extends PgxEntity<?>, ?>>> getCollectionsAsync()
Checking Collections for a Graph Using Java
Map<String, PgxCollection<? extends PgxEntity<?>, ?>> getCollections()
Checking Collections for a Graph Using Python
get_collections(self)
The returned map contains the names of the collections as keys and the collections as values. The collections can be casted to the matching collection subclass.
PGX supports special Map
collection types and allows users to map between different data types (oracle.pgx.common.types.PropertyType
). Maps can be created using PgxGraph
or PgxSession
APIs, the difference is that the latter supports only non graph-related types, and that the created maps directly depend on the session:
PgxFuture<PgxMap<K, V>> createMapAsync(PropertyType keyType, PropertyType valType)
PgxFuture<PgxMap<K, V>> createMapAsync(PropertyType keyType, PropertyType valType, String mapName)
Creating Map Collections Using Java
PgxMap<K, V> createMap(PropertyType keyType, PropertyType valType)
PgxMap<K, V> createMap(PropertyType keyType, PropertyType valType, String mapName)
Similarly, scalar variables can be created in the client session using the following methods:
PgxFuture<Scalar<T>> createScalarAsync(PropertyType type, String newScalarName)
PgxFuture<Scalar<T>> createScalarAsync(PropertyType type)
Creating Scalar Variables Using Java
Scalar<T> createScalar(PropertyType type, String newScalarName)
Scalar<T> createScalar(PropertyType type)
Creating Scalar Variables Using Python
create_scalar(self,data_type,name=None)
These collections and scalar variables can then be passed as arguments to graph algorithms. See Using Custom PGX Graph Algorithms for more information.
Parent topic: Managing Transient Data