UltipaDocs
Try Playground
  • Introduction
  • RESTful API
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Java

Types Mapping Ultipa and Java

Mapping Methods

The get() or alias() method of the Response class returns a DataItem, which embeds the query result. You should use the as<Type>() method of DataItem to cast the result to the appropriate driver type.

Java
Response response = client.uql("find().nodes() as n return n{*} limit 5");
List<Node> nodeList = response.alias("n").asNodes();

The result n coming from the database contains five nodes, each of the NODE type. The asNodes() method converts them as a list of Node objects.

Type mapping methods available on DataItem:

UQL TypeUQL AliasMethodDriver Type
Description
NODEAnyasNodes()List<Node>Maps NODE-type DataItem to a list of Node objects.
NODEAnyasFirstNode()NodeMaps the first node in a NODE-type DataItem to a Node object. Equivalent to asNodes().get(0).
EDGEAnyasEdges()List<Edge>Maps EDGE-type DataItem to a list of Edge objects.
EDGEAnyasFirstEdge()EdgeMaps the first edge in an EDGE-type DataItem to an Edge object. Equivalent to asEdges().get(0).
PATHAnyasPaths()List<Path>Maps PATH-type DataItem to a list of Path objects.
GRAPHAnyasGraph()GraphMaps GRAPH-type DataItem to a Graph object.
TABLE_graphasGraphSets()List<GraphSet>Maps DataItem with the alias _graph to a list of GraphSet objects.
TABLE_nodeSchema, _edgeSchemaasSchemas()List<Schema>Maps DataItem with the alias _nodeSchema or _edgeSchema to a list of Schema objects.
TABLE_nodeProperty, _edgePropertyasProperties()List<Property>Maps DataItem with the alias _nodeProperty or _edgeProperty to a list of Property objects.
TABLE_algoListasAlgos()List<Algo>Maps DataItem with the alias _algoList to a list of Algo objects.
TABLE_extaListasExtas()List<Exta>Maps DataItem with the alias _extaList to a list of Exta objects.
TABLE_nodeIndex, _edgeIndex, _nodeFulltext, _edgeFulltextasIndexes()List<Index>Maps DataItem with the alias _nodeIndex, _edgeIndex, _nodeFulltext or _edgeFulltext to a list of Index objects.
TABLE_privilegeasPriviliege()PriviliegeMaps DataItem with the alias _privilege to a Priviliege object.
TABLE_policyasPolicy()List<Policy>Maps DataItem with the alias _policy to a list of Policy objects.
TABLE_userasUsers()List<User>Maps DataItem with the alias _user to a list of User objects.
TABLE_statisticasStats()StatsMaps DataItem with the alias _statistic to a Stats object.
TABLE_topasProcesses()List<Process>Maps DataItem with the alias _top to a list of Process objects.
TABLE_taskasTasks()List<Task>Maps DataItem with the alias _task to a list of Task objects.
TABLEAnyasTable()TableMaps TABLE-type DataItem to a Table object.
ATTRAnyasAttr()AttrMaps ATTR-type DataItem to a Attr object.

Driver Types

NOTE

Objects of all driver types support getter methods to retrieve the value of a field and setter methods to set the value of a field, even if they are not explicitly listed below.

Node

A Node object has the following fields:

FieldType
Description
uuidLongNode UUID
idStringNode ID
schemaStringNode Schema
valuesValueNode custom properties

Methods on a Node object:

Method
Return
Description
get("<propertyName>")ObjectGet value of the given custom property of the node.
set("<propertyName>", <propertyValue>)Set value for the given custom property of the node; or add a key-value pair to the values of the node if the given <propertyName> does not exist.
Java
Response response = client.uql("find().nodes() as n return n{*} limit 5");
List<Node> nodeList = response.alias("n").asNodes();

System.out.println("ID of the 1st node: " + nodeList.get(0).getID());
System.out.println("Store name of the 1st node: " + nodeList.get(0).get("storeName"));
Output
ID of the 1st node: 47370-257954
Store name of the 1st node: Meritxell, 96

Edge

An Edge object has the following fields:

FieldType
Description
uuidLongEdge UUID
fromUuidLongStart node UUID of the edge
toUuidLongEnd node UUID of the edge
fromStringStart node ID of the edge
toStringEnd node ID of the edge
schemaStringEdge Schema
valuesValueEdge custom properties

Methods on an Edge object:

Method
Return
Description
get("<propertyName>")ObjectGet value of the given custom property of the edge.
set("<propertyName>", <propertyValue>Set value for the given custom property of the edge; or add a key-value pair to the values of the edge if the given <propertyName> does not exist.
Java
Response response = client.uql("find().edges() as e return e{*} limit 5");
Edge edge = response.alias("e").asFirstEdge();
System.out.println("Values of the 1st edge: " + edge.getValues());
Output
Values of the 1st edge: {distanceMeters=20, duration=21s, staticDuration=25s, travelMode=Walk, transportationCost=46}

Path

A Path object has the following fields:

Field
Type
Description
nodesList<Node>Node list of the path
edgesList<Edge>Edge list of the path
nodeSchemasMap<String, Schema>Map of all node schemas of the path
edgeSchemasMap<String, Schema>Map of all edge schemas of the path

Methods on a Path object:

Method
Return
Description
length()IntegerGet length of the path, i.e., the number of edges in the path.
Java
Response response = client.uql("n().e()[:2].n() as paths return paths{*} limit 5");
List<Path> pathList = response.alias("paths").asPaths();

System.out.println("Length of the 1st path: " + pathList.get(0).length());
System.out.println("Edge list of the 1st path: " + pathList.get(0).getEdges());
System.out.println("Information of the 2nd node in the 1st path: " + pathList.get(0).getNodes().get(1).toJson());
Output
Length of the 1st path: 2
Edge list of the 1st path: [Edge(uuid=591, fromUuid=20, toUuid=1, from=15219-158845, to=47370-257954, schema=transport, values={distanceMeters=10521283, duration=527864s, staticDuration=52606s, travelMode=Airplane, transportationCost=21043}), Edge(uuid=599, fromUuid=21, toUuid=20, from=15474-156010, to=15219-158845, schema=transport, values={distanceMeters=233389, duration=13469s, staticDuration=1167s, travelMode=Airplane, transportationCost=467})]
Information of the 2nd node in the 1st path: {"brand":"Starbucks","storeName":"Las Palmas","ownershipType":"Licensed","city":"Pilar","provinceState":"B","timezone":"GMT-03:00 America/Argentina/Bu","point":{"latitude":-33.39,"longitude":-60.22},"_uuid":20,"_id":"15219-158845","schema":"warehouse"}

Graph

A Graph object has the following fields:

Field
Type
Description
nodesList<Node>Node list of the path
edgesList<Edge>Edge list of the path
nodeSchemasMap<String, Schema>Map of all node schemas of the path
edgeSchemasMap<String, Schema>Map of all edge schemas of the path
Java
Response response = client.uql("n(as n1).re(as e).n(as n2).limit(3) with toGraph(collect(n1), collect(n2), collect(e)) as graph return graph");
Graph graph = response.alias("graph").asGraph();
List<Node> nodes = graph.getNodes();
List<Edge> edges = graph.getEdges();

System.out.println("Node IDs:");
for (Node node : nodes) {
    System.out.println(node.getID());
}
System.out.println("Edge UUIDs:");
for (Edge edge : edges) {
    System.out.println(edge.getUUID());
}
Output
Node IDs:
ad304833
u604131
ad534784
ad6880
Edge UUIDs:
363347
774098
527786
3

GraphSet

A GraphSet object has the following fields:

Field
Type
Description
idIntegerGraphset ID
nameStringGraphset name
descriptionStringGraphset description
totalNodesLongTotal number of nodes in the graphset
totalEdgesLongTotal number of edges in the graphset
statusStringGraphset status (MOUNTED, MOUNTING, or UNMOUNTED)
Java
Response response = client.uql("show().graph()");
List<GraphSet> graphSetList = response.alias("_graph").asGraphSets();
for (GraphSet graphSet : graphSetList) {
    if (graphSet.getStatus().equals("UNMOUNTED")) {
        System.out.println(graphSet.getName());
    }
}
Output
DFS_EG
cyber
netflow

Schema

A Schema object has the following fields:

Field
Type
Description
nameStringSchema name
descriptionStringSchema description
propertiesList<Property>Property list of the schema
dbTypeUltipa.DBTypeSchema type (DBNODE or DBEDGE)
totalIntegerTotal number of nodes or edges of the schema
Java
Response response = client.uql("show().node_schema()");
List<Schema> schemaList = response.alias("_nodeSchema").asSchemas();
for (Schema schema : schemaList) {
    System.out.println(schema.getName() + " has " + schema.getTotal() + " nodes");
}
Output
default has 0 nodes
user has 1092511 nodes
ad has 846811 nodes

Property

A Property object has the following fields:

Field
Type
Description
nameStringProperty name
descriptionStringProperty description
schemaStringAssociated schema of the property
typeStringProperty data type
lteBooleanProperty LTE status (true or false)
Java
Response response = client.uql("show().node_property(@user)");
List<Property> propertyList = response.alias("_nodeProperty").asProperties();
for (Property property : propertyList) {
    if (property.getLte()) {
        System.out.println("LTE-ed property name: " + property.getName());
    }
}
Output
LTE-ed property name: cms_group_id

Algo

An Algo object has the following fields:

Field
Type
Description
nameStringAlgorithm name
descStringAlgorithm description
versionStringAlgorithm version
detailStringAlgorithm parameters
Java
Response res = client.uql("show().algo()");
List<Algo> algoList = res.alias("_algoList").asAlgos();
System.out.println(algoList.get(0).toString());
Output
Algo(name=fastRP, desc={"name":"fastRP","description":"Fast and Accurate Network Embeddings via Very Sparse Random Projection","version":"1.0.1","parameters":{"dimension":"int,required","normalizationStrength":"float,optional, 0 as default","iterationWeights":"float[],optional,[0.0,1.0,1.0] as default","edge_schema_property":"optional,for weighted random projection","node_schema_property":"optional","propertyDimension":"int,optional, maximum value is dimension","limit":"optional,-1 for all results, >=0 partial results"},"write_to_db_parameters":{"property":"set write back property name for each schema and nodes"},"write_to_file_parameters":{"filename":"set file name"},"result_opt":"27"}, version=null, params=null)

Exta

NOTE

An exta is a custom algorithm developed by users.

An Exta object has the following fields:

Field
Type
Description
nameStringExta name
authorStringExta author
versionStringExta version
detailStringContent of the YML configuration file of the Exta
Java
Response response = client.uql("show().exta()");
List<Exta> extaList = response.alias("_extaList").asExtas();
System.out.println(extaList.get(0).getName());
Output
page_rank

Index

An Index object has the following fields:

Field
Type
Description
nameStringIndex name
propertiesStringProperty name of the index
schemaStringSchema name of the index
statusStringIndex status (done or creating)
sizeStringIndex size in bytes
dbTypeUltipa.DBTypeIndex type (DBNODE or DBEDGE)
Java
Response response = client.uql("show().index()");
List<Index> indexList = response.alias("_nodeIndex").asIndexes();

for (Index index : indexList) {
    System.out.println(index.getSchema() + " " + index.getProperties() + " " + index.getSize());
}
Output
account name 0
movie name 2526
Java
Response response = client.uql("show().fulltext()");
List<Index> indexList = response.alias("_edgeFulltext").asIndexes();

for (Index index : indexList) {
    System.out.println(index.getName() + " " + index.getProperties() + " " + index.getSchema());
}
Output
contentFull content review

Privilege

A Privilege object has the following fields:

Field
Type
Description
systemPrivilegesList<String>System privileges
graphPrivilegesList<String>Graph privileges
Java
Response response = client.uql("show().privilege()");
Privilege privilege = response.alias("_privilege").asPrivilege();
System.out.println(privilege.getSystemPrivileges());
Output
[TRUNCATE, COMPACT, CREATE_GRAPH, SHOW_GRAPH, DROP_GRAPH, ALTER_GRAPH, MOUNT_GRAPH, UNMOUNT_GRAPH, TOP, KILL, STAT, SHOW_POLICY, CREATE_POLICY, DROP_POLICY, ALTER_POLICY, SHOW_USER, CREATE_USER, DROP_USER, ALTER_USER, GRANT, REVOKE, SHOW_PRIVILEGE]

Policy

A Policy object has the following fields:

Field
Type
Description
nameStringPolicy name
systemPrivilegesList<String>System privileges included in the policy
graphPrivilegesMap<String, List<String>>Graph privileges and the corresponding graphsets included in the policy
propertyPrivilegesPropertyPrivilegeProperty privileges included in the policy
policiesList<String>Policies included in the policy
Java
Response response = client.uql("show().policy()");
List<Policy> policyList = response.alias("_policy").asPolicies();
for (Policy policy : policyList) {
    System.out.println(policy.getName());
}
Output
manager
operator

User

A User object has the following fields:

Field
Type
Description
usernameStringUsername
createStringWhen the user was created
systemPrivilegesList<String>System privileges granted to the user
graphPrivilegesMap<String, List<String>>Graph privileges and the corresponding graphsets granted to the user
propertyPrivilegesPropertyPrivilegeProperty privileges granted to the user
policiesList<String>Policies granted to the user
Java
Response response = client.uql("show().user('Tester')");
List<User> user = response.alias("_user").asUsers();
System.out.println(user.get(0).toString());
Output
User(username=Tester, create=Fri Jul 26 14:10:06 CST 2024, systemPrivileges=[MOUNT_GRAPH, SHOW_GRAPH], graphPrivileges={Ad_Click=[FIND_EDGE, FIND_NODE], DFS_EG=[UPDATE, INSERT]}, propertyPrivileges=PropertyPrivilege(node=PropertyPrivilegeElement(read=[], write=[], deny=[]), edge=PropertyPrivilegeElement(read=[], write=[], deny=[])), policies=[operator])

Stats

A Stats object has the following fields:

Field
Type
Description
cpuUsageStringCPU usage in percentage
memUsageStringMemory usage in megabytes
expiredDateStringExpiration date of the license
cpuCoresStringNumber of CPU cores
companyStringCompany name
serverTypeStringServer type
versionStringVersion of the server
Java
Response response = client.uql("stats()");
Stats stats = response.get(0).asStats();
System.out.println("CPU usage: " + stats.getCpuUsage() + "%");
System.out.println("Memory usage: " + stats.getMemUsage());
Output
CPU usage: 5.415697%
Memory usage: 9292.265625

Process

A Process object has the following fields:

Field
Type
Description
processIdStringProcess ID
processUqlStringThe UQL run with the process
statusStringProcess status
durationStringThe duration in seconds the task has run so far
Java
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("amz");

Response response = client.uql("top()", requestConfig);
List<Process> processList = response.alias("_top").asProcesses();
for (Process process : processList) {
    System.out.println(process.getProcessId());
}
Output
a_2_569_2
a_3_367_1

Task

A Task object has the following fields:

Field
Type
Description
taskInfoTaskInfoTask information including taskId, serverId, algoName, startTime, etc.
paramMap<String, Object>Algorithm parameters and their corresponding values
resultMap<String, Object>Algorithm result and statistics and their corresponding values
errorMsgStringError message of the task
Java
Response response = client.uql("show().task()", requestConfig);
List<Task> tasks = response.alias("_task").asTasks();
System.out.println(tasks.get(0).getTaskInfo().getAlgoName());
System.out.println(tasks.get(0).getParam().toString());
System.out.println(tasks.get(0).getResult().toString());
Output
degree
{order=desc, limit=10}
{total_degree=590.000000, avarage_degree=1.940789, result_files=top10}

Table

A Table object has the following fields:

Field
Type
Description
tableNameStringTable name
headersList<Header>Table headers
rowsList<List<Object>>Table rows

Methods on a Table object:

Method
Return
Description
toKV()List<Value>Convert all rows of the table to a key-value list.
Java
Response response = client.uql("find().nodes() as n return table(n._id, n._uuid) as myTable limit 5");
Table table = response.alias("myTable").asTable();
System.out.println("2nd row in table: " + table.toKV().get(1));
Output
2nd row in table: {n._id=u604510, n._uuid=2}

Attr

A Attr object has the following fields:

Field
Type
Description
nameStringAttr name
valuesList<Object>Attr rows
typeUltipa.PropertyTypeAttr type
Java
Response response = client.uql("find().nodes({@ad}) as n return n.brand limit 5");
Attr attr = response.alias("n.brand").asAttr();
System.out.println(attr.getValues());
Output
[14655, 14655, 14655, 14655, 434760]