uql()
Method and class:
Response uql(String uql)
Response uql(String uql, RequestConfig requestConfig)
Sending uql()
request will return class Response.
Response has below fileds:
Field | Type | Description |
---|---|---|
aliases | List<Alias> | aliases and types of each return value |
items | Map<String, DataItem> | aliases and values (DataItem) of each return value |
insertNodesReply | Ultipa.InsertNodesReply | result of batch insert of nodes |
insertEdgesReply | Ultipa.InsertEdgesReply | result of batch insert of edges |
exportData | ExportData | result of export data |
explainPlan | ExplainPlan | UQL statement explanation tree |
status | UStatus | status of request execution |
statistic | Statistic | statistics of request execution, including timecost, metadata affected, etc. |
Response has below methods:
Method | Type | Description |
---|---|---|
get(int index) | DataItem | acquire an alias as DataItem by index |
alias(String name) | DataItem | acquire an alias as DataItem by name |
Alias types such as NODE, EDGE and PATH can be connverted to corresponding classes using methods of class DataItem, see next chapter Alias Structs for detail.
get()
Example: Send UQL return now() as currentTime, pi() as PI
to server and print the first alias in json format
public class Main {
public static void main(String[] args) {
// omit code of establishing server connection 'conn'
Response res = conn.uql("return now() as currentTime, pi() as PI");
System.out.println(res.get(0).toJson());
}
}
Output:
["{\"type\":\"DATETIME\",\"values\":[\"Dec 13, 2022 7:39:38 AM\"],\"name\":\"currentTime\"}"]
alias()
Example: Send UQL return now() as currentTime, pi() as PI
to server and print the 2nd alias in json format
public class Main {
public static void main(String[] args) {
// omit code of establishing server connection 'conn'
Response res = conn.uql("return now() as currentTime, pi() as PI");
System.out.println(res.alias("PI").toJson());
}
}
Output:
["{\"type\":\"DOUBLE\",\"values\":[3.14159265358979],\"name\":\"PI\"}"]