use of com.alibaba.maxgraph.structure.Vertex in project GraphScope by alibaba.
the class VertexStreamObserver method onCompleted.
@Override
public void onCompleted() {
if (!vertexCountList.isEmpty()) {
for (Map.Entry<ElementId, Integer> entry : vertexCountList.entrySet()) {
ElementId elementId = entry.getKey();
MxVertex vertex = new MxVertex(new Vertex(elementId, schema.getElement(elementId.typeId()).getLabel(), Maps.newHashMap(), this.graph.getBaseGraph()), this.graph);
if (vertexCacheFlag) {
vertexCache.put(elementId, vertex);
}
for (int i = 0; i < entry.getValue(); i++) {
resultProcessor.process(vertex);
}
}
}
resultProcessor.finish();
latch.countDown();
}
use of com.alibaba.maxgraph.structure.Vertex in project GraphScope by alibaba.
the class EdgeResponseFunction method apply.
@Override
public Edge apply(StoreApi.GraphEdgeReponse edgeReponse) {
CompositeId eid = new CompositeId(edgeReponse.getEdgeId(), edgeReponse.getTypeId());
GraphElement element = schema.getElement(eid.typeId());
String label = element.getLabel();
Map<String, Object> properties = RpcProcessorUtils.deserializeProperty(edgeReponse.getPros().toByteArray(), element, schema);
GremlinQuery.VertexId srcId = edgeReponse.getSrcId();
GremlinQuery.VertexId dstId = edgeReponse.getDstId();
Iterator<Vertex> vertexIterator = graph.getVertex(Sets.newHashSet(new CompositeId(srcId.getId(), srcId.getTypeId()), new CompositeId(dstId.getId(), dstId.getTypeId())));
Vertex srcVertex = null, dstVertex = null;
while (vertexIterator.hasNext()) {
Vertex vertex = vertexIterator.next();
if (vertex.id.id() == srcId.getId()) {
srcVertex = vertex;
}
if (vertex.id.id() == dstId.getId()) {
dstVertex = vertex;
}
}
if (null == srcVertex) {
try {
GraphElement graphElement = schema.getElement(srcId.getTypeId());
srcVertex = new Vertex(new CompositeId(srcId.getId(), srcId.getTypeId()), graphElement.getLabel(), Maps.newHashMap(), graph);
} catch (Exception ignored) {
srcVertex = new Vertex(new CompositeId(srcId.getId(), srcId.getTypeId()), "", Maps.newHashMap(), graph);
}
}
if (null == dstVertex) {
try {
GraphElement graphElement = schema.getElement(dstId.getTypeId());
dstVertex = new Vertex(new CompositeId(dstId.getId(), dstId.getTypeId()), graphElement.getLabel(), Maps.newHashMap(), graph);
} catch (Exception ignored) {
dstVertex = new Vertex(new CompositeId(dstId.getId(), dstId.getTypeId()), "", Maps.newHashMap(), graph);
}
}
return new Edge(eid, label, properties, srcVertex, dstVertex, this.graph);
}
use of com.alibaba.maxgraph.structure.Vertex in project GraphScope by alibaba.
the class VertexResponseFunction method apply.
@Override
public Vertex apply(GremlinQuery.VertexResponse nextV) {
GremlinQuery.VertexId id = nextV.getId();
CompositeId rId = new CompositeId(id.getId(), id.getTypeId());
GraphElement type = schema.getElement(id.getTypeId());
Map<String, Object> properties = RpcProcessorUtils.deserializeProperty(nextV.getPros().toByteArray(), type, schema);
return new Vertex(rId, type.getLabel(), properties, this.graph);
}
Aggregations