QueryServiceApi¶
所有URI均相对于{INTERACTIVE_ADMIN_ENDPOINT}
尽管Interactive在存储层面支持多图,但查询服务目前只能运行在单个图上。这意味着在任何给定时间,只有一张图能提供查询服务。如果您尝试向当前未运行的图提交查询,系统将直接抛出错误。
方法 |
HTTP请求 |
描述 |
|---|---|---|
POST /v1/graph/{graph_id}/query |
向指定图ID标识的图提交查询 |
|
POST /v1/graph/current/query |
向当前运行的图提交查询 |
调用过程¶
结果
callProcedure(graphId, request)
向指定图提交过程调用查询。查询的输出格式由results.proto定义。
关于存储过程的创建,请参考CypherStoredProcedure和CppStoredProcedure。
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.ApiClient;
import com.alibaba.graphscope.interactive.ApiException;
import com.alibaba.graphscope.interactive.Configuration;
import com.alibaba.graphscope.interactive.models.*;
import com.alibaba.graphscope.interactive.api.QueryServiceApi;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
//Create the graph and register procedure first, and start service on this graph.
String graphId = "2";
String procedureId = "testProcedure";
QueryRequest request = new QueryRequest();
request.setQueryName(procedureId);
request.addArgumentsItem(
new TypedValue()
.value(1)
.type(
new GSDataType(
new PrimitiveType()
.primitiveType(
PrimitiveType.PrimitiveTypeEnum
.SIGNED_INT32))));
Result<IrResult.CollectiveResults> queryRes = session.callProcedure(graphId, request);
if (!queryRes.isOk()) {
System.out.println("Failed to call procedure: " + queryRes.getStatusMessage());
return;
} else {
System.out.println("Called procedure: " + queryRes.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
graphId |
String |
||
请求体 |
QueryRequest |
[可选] |
返回类型¶
HTTP请求头¶
内容类型: text/plain
Accept: text/plain
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
成功执行。如果失败则为空? |
- |
500 |
服务器内部错误 |
- |
在当前图上调用过程¶
结果
callProcedure(body)
向运行中的图提交查询。
示例¶
// Import classes:
import com.alibaba.graphscope.interactive.ApiClient;
import com.alibaba.graphscope.interactive.ApiException;
import com.alibaba.graphscope.interactive.Configuration;
import com.alibaba.graphscope.interactive.models.*;
import com.alibaba.graphscope.interactive.api.QueryServiceApi;
public class Example {
public static void main(String[] args) {
Driver driver = Driver.connect();
Session session = driver.session();
//Create the graph and register procedure first, and start service on this graph.
String procedureId = "testProcedure";
QueryRequest request = new QueryRequest();
request.setQueryName(procedureId);
request.addArgumentsItem(
new TypedValue()
.value(1)
.type(
new GSDataType(
new PrimitiveType()
.primitiveType(
PrimitiveType.PrimitiveTypeEnum
.SIGNED_INT32))));
// Note that graph id is not specified, will try to call the procedure on the current running graph, if exits.
Result<IrResult.CollectiveResults> queryRes = session.callProcedure(request);
if (!queryRes.isOk()) {
System.out.println("Failed to call procedure: " + queryRes.getStatusMessage());
return;
} else {
System.out.println("Called procedure: " + queryRes.getValue());
}
}
}
参数¶
名称 |
类型 |
描述 |
备注 |
|---|---|---|---|
body |
byte[] |
[可选] |
返回类型¶
授权¶
无需授权
HTTP请求头¶
内容类型: text/plain
Accept: text/plain
HTTP响应详情¶
状态码 |
描述 |
响应头 |
|---|---|---|
200 |
成功执行。如果失败则为空? |
- |
500 |
服务器内部错误 |
- |