mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-06-27 03:20:10 +00:00
feat(knext&server)add api for vertex batch query
This commit is contained in:
parent
c00fd998eb
commit
43ef0148d4
@ -52,5 +52,7 @@ from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest
|
||||
from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord
|
||||
from knext.graph.rest.models.query_vertex_request import QueryVertexRequest
|
||||
from knext.graph.rest.models.query_vertex_response import QueryVertexResponse
|
||||
from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest
|
||||
from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse
|
||||
from knext.graph.rest.models.vertex_record import VertexRecord
|
||||
from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse
|
||||
|
@ -19,6 +19,7 @@ from knext.graph import (
|
||||
GetPageRankScoresRequestStartNodes,
|
||||
WriterGraphRequest,
|
||||
QueryVertexRequest,
|
||||
BatchQueryVertexRequest,
|
||||
ExpendOneHopRequest,
|
||||
EdgeTypeName,
|
||||
)
|
||||
@ -76,6 +77,14 @@ class GraphClient(Client):
|
||||
)
|
||||
return self._rest_client.graph_query_vertex_post(query_vertex_request=request)
|
||||
|
||||
def batch_query_vertex(self, type_name: str, biz_ids: List[str]):
|
||||
request = BatchQueryVertexRequest(
|
||||
project_id=self._project_id, type_name=type_name, biz_ids=biz_ids
|
||||
)
|
||||
return self._rest_client.graph_batch_query_vertex_post(
|
||||
batch_query_vertex_request=request
|
||||
)
|
||||
|
||||
def expend_one_hop(
|
||||
self,
|
||||
type_name: str,
|
||||
|
@ -52,5 +52,7 @@ from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest
|
||||
from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord
|
||||
from knext.graph.rest.models.query_vertex_request import QueryVertexRequest
|
||||
from knext.graph.rest.models.query_vertex_response import QueryVertexResponse
|
||||
from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest
|
||||
from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse
|
||||
from knext.graph.rest.models.vertex_record import VertexRecord
|
||||
from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse
|
||||
|
@ -989,3 +989,121 @@ class GraphApi(object):
|
||||
_request_timeout=local_var_params.get("_request_timeout"),
|
||||
collection_formats=collection_formats,
|
||||
)
|
||||
|
||||
def graph_batch_query_vertex_post(self, **kwargs): # noqa: E501
|
||||
"""batch_query_vertex # noqa: E501
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
>>> thread = api.graph_batch_query_vertex_post(async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param BatchQueryVertexRequest batch_query_vertex_request:
|
||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is True.
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:return: BatchQueryVertexResponse
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
kwargs["_return_http_data_only"] = True
|
||||
return self.graph_batch_query_vertex_post_with_http_info(**kwargs) # noqa: E501
|
||||
|
||||
def graph_batch_query_vertex_post_with_http_info(self, **kwargs): # noqa: E501
|
||||
"""batch_query_vertex # noqa: E501
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
>>> thread = api.graph_batch_query_vertex_post_with_http_info(async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param BatchQueryVertexRequest batch_query_vertex_request:
|
||||
:param _return_http_data_only: response data without head status code
|
||||
and headers
|
||||
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is True.
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:return: tuple(BatchQueryVertexResponse, status_code(int), headers(HTTPHeaderDict))
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
local_var_params = locals()
|
||||
|
||||
all_params = ["batch_query_vertex_request"]
|
||||
all_params.extend(
|
||||
[
|
||||
"async_req",
|
||||
"_return_http_data_only",
|
||||
"_preload_content",
|
||||
"_request_timeout",
|
||||
]
|
||||
)
|
||||
|
||||
for key, val in six.iteritems(local_var_params["kwargs"]):
|
||||
if key not in all_params:
|
||||
raise ApiTypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method graph_batch_query_vertex_post" % key
|
||||
)
|
||||
local_var_params[key] = val
|
||||
del local_var_params["kwargs"]
|
||||
|
||||
collection_formats = {}
|
||||
|
||||
path_params = {}
|
||||
|
||||
query_params = []
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
|
||||
body_params = None
|
||||
if "batch_query_vertex_request" in local_var_params:
|
||||
body_params = local_var_params["batch_query_vertex_request"]
|
||||
# HTTP header `Accept`
|
||||
header_params["Accept"] = self.api_client.select_header_accept(
|
||||
["application/json"]
|
||||
) # noqa: E501
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params[
|
||||
"Content-Type"
|
||||
] = self.api_client.select_header_content_type( # noqa: E501
|
||||
["application/json"]
|
||||
) # noqa: E501
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = [] # noqa: E501
|
||||
|
||||
return self.api_client.call_api(
|
||||
"/graph/batchQueryVertex",
|
||||
"POST",
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=local_var_files,
|
||||
response_type="BatchQueryVertexResponse", # noqa: E501
|
||||
auth_settings=auth_settings,
|
||||
async_req=local_var_params.get("async_req"),
|
||||
_return_http_data_only=local_var_params.get(
|
||||
"_return_http_data_only"
|
||||
), # noqa: E501
|
||||
_preload_content=local_var_params.get("_preload_content", True),
|
||||
_request_timeout=local_var_params.get("_request_timeout"),
|
||||
collection_formats=collection_formats,
|
||||
)
|
||||
|
@ -36,5 +36,7 @@ from knext.graph.rest.models.expend_one_hop_request import ExpendOneHopRequest
|
||||
from knext.graph.rest.models.lpg_property_record import LpgPropertyRecord
|
||||
from knext.graph.rest.models.query_vertex_request import QueryVertexRequest
|
||||
from knext.graph.rest.models.query_vertex_response import QueryVertexResponse
|
||||
from knext.graph.rest.models.batch_query_vertex_request import BatchQueryVertexRequest
|
||||
from knext.graph.rest.models.batch_query_vertex_response import BatchQueryVertexResponse
|
||||
from knext.graph.rest.models.vertex_record import VertexRecord
|
||||
from knext.graph.rest.models.expend_one_hop_response import ExpendOneHopResponse
|
||||
|
@ -0,0 +1,202 @@
|
||||
# coding: utf-8
|
||||
# Copyright 2023 OpenSPG Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
# in compliance with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
# or implied.
|
||||
|
||||
|
||||
"""
|
||||
knext
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from knext.common.rest.configuration import Configuration
|
||||
|
||||
|
||||
class BatchQueryVertexRequest(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
"""
|
||||
Attributes:
|
||||
openapi_types (dict): The key is attribute name
|
||||
and the value is attribute type.
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
openapi_types = {"project_id": "int", "type_name": "str", "biz_ids": "list[str]"}
|
||||
|
||||
attribute_map = {
|
||||
"project_id": "projectId",
|
||||
"type_name": "typeName",
|
||||
"biz_ids": "bizIds",
|
||||
}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
project_id=None,
|
||||
type_name=None,
|
||||
biz_ids=None,
|
||||
local_vars_configuration=None,
|
||||
): # noqa: E501
|
||||
"""BatchQueryVertexRequest - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
|
||||
self._project_id = None
|
||||
self._type_name = None
|
||||
self._biz_ids = None
|
||||
self.discriminator = None
|
||||
|
||||
self.project_id = project_id
|
||||
self.type_name = type_name
|
||||
self.biz_ids = biz_ids
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
"""Gets the project_id of this BatchQueryVertexRequest. # noqa: E501
|
||||
|
||||
|
||||
:return: The project_id of this BatchQueryVertexRequest. # noqa: E501
|
||||
:rtype: int
|
||||
"""
|
||||
return self._project_id
|
||||
|
||||
@project_id.setter
|
||||
def project_id(self, project_id):
|
||||
"""Sets the project_id of this BatchQueryVertexRequest.
|
||||
|
||||
|
||||
:param project_id: The project_id of this BatchQueryVertexRequest. # noqa: E501
|
||||
:type: int
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation and project_id is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `project_id`, must not be `None`"
|
||||
) # noqa: E501
|
||||
|
||||
self._project_id = project_id
|
||||
|
||||
@property
|
||||
def type_name(self):
|
||||
"""Gets the type_name of this BatchQueryVertexRequest. # noqa: E501
|
||||
|
||||
|
||||
:return: The type_name of this BatchQueryVertexRequest. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._type_name
|
||||
|
||||
@type_name.setter
|
||||
def type_name(self, type_name):
|
||||
"""Sets the type_name of this BatchQueryVertexRequest.
|
||||
|
||||
|
||||
:param type_name: The type_name of this BatchQueryVertexRequest. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation and type_name is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `type_name`, must not be `None`"
|
||||
) # noqa: E501
|
||||
|
||||
self._type_name = type_name
|
||||
|
||||
@property
|
||||
def biz_ids(self):
|
||||
"""Gets the biz_ids of this BatchQueryVertexRequest. # noqa: E501
|
||||
|
||||
|
||||
:return: The biz_ids of this BatchQueryVertexRequest. # noqa: E501
|
||||
:rtype: list[str]
|
||||
"""
|
||||
return self._biz_ids
|
||||
|
||||
@biz_ids.setter
|
||||
def biz_ids(self, biz_ids):
|
||||
"""Sets the biz_ids of this BatchQueryVertexRequest.
|
||||
|
||||
|
||||
:param biz_ids: The biz_ids of this BatchQueryVertexRequest. # noqa: E501
|
||||
:type: list[str]
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation and biz_ids is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `biz_ids`, must not be `None`"
|
||||
) # noqa: E501
|
||||
|
||||
self._biz_ids = biz_ids
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.openapi_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(
|
||||
map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)
|
||||
)
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(
|
||||
map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict")
|
||||
else item,
|
||||
value.items(),
|
||||
)
|
||||
)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, BatchQueryVertexRequest):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, BatchQueryVertexRequest):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
@ -0,0 +1,134 @@
|
||||
# coding: utf-8
|
||||
# Copyright 2023 OpenSPG Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
# in compliance with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
# or implied.
|
||||
|
||||
|
||||
"""
|
||||
knext
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from knext.common.rest.configuration import Configuration
|
||||
|
||||
|
||||
class BatchQueryVertexResponse(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
"""
|
||||
Attributes:
|
||||
openapi_types (dict): The key is attribute name
|
||||
and the value is attribute type.
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
openapi_types = {"vertices": "list[VertexRecord]"}
|
||||
|
||||
attribute_map = {"vertices": "vertices"}
|
||||
|
||||
def __init__(self, vertices=None, local_vars_configuration=None): # noqa: E501
|
||||
"""BatchQueryVertexResponse - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
|
||||
self._vertices = None
|
||||
self.discriminator = None
|
||||
|
||||
self.vertices = vertices
|
||||
|
||||
@property
|
||||
def vertices(self):
|
||||
"""Gets the vertices of this BatchQueryVertexResponse. # noqa: E501
|
||||
|
||||
|
||||
:return: The vertices of this BatchQueryVertexResponse. # noqa: E501
|
||||
:rtype: list[VertexRecord]
|
||||
"""
|
||||
return self._vertices
|
||||
|
||||
@vertices.setter
|
||||
def vertices(self, vertices):
|
||||
"""Sets the vertices of this BatchQueryVertexResponse.
|
||||
|
||||
|
||||
:param vertices: The vertices of this BatchQueryVertexResponse. # noqa: E501
|
||||
:type: list[VertexRecord]
|
||||
"""
|
||||
if (
|
||||
self.local_vars_configuration.client_side_validation and vertices is None
|
||||
): # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `vertices`, must not be `None`"
|
||||
) # noqa: E501
|
||||
|
||||
self._vertices = vertices
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.openapi_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(
|
||||
map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)
|
||||
)
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(
|
||||
map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict")
|
||||
else item,
|
||||
value.items(),
|
||||
)
|
||||
)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, BatchQueryVertexResponse):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, BatchQueryVertexResponse):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Ant Group
|
||||
* Copyright (c) 2004-2024 All Rights Reserved.
|
||||
*/
|
||||
package com.antgroup.openspg.server.api.facade.dto.service.request;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BatchQueryVertexRequest {
|
||||
|
||||
private Long projectId;
|
||||
private String typeName;
|
||||
private List<String> bizIds;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Ant Group
|
||||
* Copyright (c) 2004-2024 All Rights Reserved.
|
||||
*/
|
||||
package com.antgroup.openspg.server.api.facade.dto.service.response;
|
||||
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.VertexRecord;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BatchQueryVertexResponse {
|
||||
|
||||
private List<VertexRecord> vertices;
|
||||
}
|
@ -29,10 +29,7 @@ import com.antgroup.openspg.core.schema.model.type.BaseSPGType;
|
||||
import com.antgroup.openspg.core.schema.model.type.ConceptList;
|
||||
import com.antgroup.openspg.core.schema.model.type.ProjectSchema;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.request.*;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ExpendOneHopResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.QueryVertexResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.*;
|
||||
import com.antgroup.openspg.server.api.http.server.HttpBizCallback;
|
||||
import com.antgroup.openspg.server.api.http.server.HttpBizTemplate;
|
||||
import com.antgroup.openspg.server.api.http.server.HttpResult;
|
||||
@ -276,4 +273,25 @@ public class GraphController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/batchQueryVertex", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public HttpResult<BatchQueryVertexResponse> batchQueryVertex(
|
||||
@RequestBody BatchQueryVertexRequest request) {
|
||||
return HttpBizTemplate.execute2(
|
||||
new HttpBizCallback<BatchQueryVertexResponse>() {
|
||||
@Override
|
||||
public void check() {
|
||||
AssertUtils.assertParamObjectIsNotNull("request", request);
|
||||
AssertUtils.assertParamObjectIsNotNull("projectId", request.getProjectId());
|
||||
AssertUtils.assertParamObjectIsNotNull("typeName", request.getTypeName());
|
||||
AssertUtils.assertParamObjectIsNotNull("bizIds", request.getBizIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatchQueryVertexResponse action() {
|
||||
return graphManager.batchQueryVertex(request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,7 @@
|
||||
package com.antgroup.openspg.server.biz.service;
|
||||
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.request.*;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ExpendOneHopResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.QueryVertexResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.*;
|
||||
import java.util.List;
|
||||
|
||||
public interface GraphManager {
|
||||
@ -36,5 +33,7 @@ public interface GraphManager {
|
||||
|
||||
QueryVertexResponse queryVertex(QueryVertexRequest request);
|
||||
|
||||
BatchQueryVertexResponse batchQueryVertex(BatchQueryVertexRequest request);
|
||||
|
||||
ExpendOneHopResponse expendOneHop(ExpendOneHopRequest request);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package com.antgroup.openspg.server.biz.service.impl;
|
||||
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.BaseLPGGraphStoreClient;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.GraphStoreClientDriverManager;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.BatchVertexLPGRecordQuery;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.OneHopLPGRecordQuery;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.PageRankCompete;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.cmd.VertexLPGRecordQuery;
|
||||
@ -25,10 +26,7 @@ import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.Vert
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.record.struct.GraphLPGRecordStruct;
|
||||
import com.antgroup.openspg.cloudext.interfaces.graphstore.model.lpg.schema.EdgeTypeName;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.request.*;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ExpendOneHopResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.ManipulateDataResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.PageRankScoreInstance;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.QueryVertexResponse;
|
||||
import com.antgroup.openspg.server.api.facade.dto.service.response.*;
|
||||
import com.antgroup.openspg.server.biz.common.ProjectManager;
|
||||
import com.antgroup.openspg.server.biz.service.GraphManager;
|
||||
import com.antgroup.openspg.server.biz.service.convertor.InstanceConvertor;
|
||||
@ -247,4 +245,28 @@ public class GraphManagerImpl implements GraphManager {
|
||||
response.setVertex(struct.getVertices().get(0));
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatchQueryVertexResponse batchQueryVertex(BatchQueryVertexRequest request) {
|
||||
String graphStoreUrl = projectManager.getGraphStoreUrl(request.getProjectId());
|
||||
BaseLPGGraphStoreClient lpgGraphStoreClient =
|
||||
(BaseLPGGraphStoreClient) GraphStoreClientDriverManager.getClient(graphStoreUrl);
|
||||
|
||||
BatchQueryVertexResponse response = new BatchQueryVertexResponse();
|
||||
response.setVertices(Lists.newArrayList());
|
||||
|
||||
if (CollectionUtils.isEmpty(request.getBizIds())) {
|
||||
return response;
|
||||
}
|
||||
|
||||
Set<String> idSet = new HashSet<>(request.getBizIds());
|
||||
|
||||
BatchVertexLPGRecordQuery query = new BatchVertexLPGRecordQuery(idSet, request.getTypeName());
|
||||
GraphLPGRecordStruct struct = (GraphLPGRecordStruct) lpgGraphStoreClient.queryRecord(query);
|
||||
|
||||
if (struct != null && !struct.getVertices().isEmpty()) {
|
||||
response.setVertices(struct.getVertices());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user