Search in sources :

Example 1 with VertexResponseFunction

use of com.alibaba.maxgraph.iterator.function.VertexResponseFunction in project GraphScope by alibaba.

the class RemoteProxy method scan.

public Iterator<Vertex> scan(Set<String> labelList) {
    Pair<GraphSchema, Long> pair = schemaFetcher.getSchemaSnapshotPair();
    Set<Integer> labelIdList = Sets.newHashSet();
    if (null == labelList || labelList.isEmpty()) {
        labelIdList.add(0);
    } else {
        for (String label : labelList) {
            try {
                labelIdList.add(pair.getLeft().getElement(label).getLabelId());
            } catch (Exception ignored) {
            }
        }
    }
    if (labelIdList.isEmpty()) {
        return new ArrayList<Vertex>().iterator();
    }
    List<Iterator<VertexResponse>> resList = Lists.newArrayList();
    VertexScanRequest vertexScanRequest = VertexScanRequest.newBuilder().setTypeId(-1).setOrder(false).build();
    Iterator<VertexResponse> scanResult = GremlinServiceGrpc.newBlockingStub(this.channel).withDeadlineAfter(timeout, TimeUnit.SECONDS).scan(vertexScanRequest);
    resList.add(scanResult);
    return new IteratorList<>(resList, new VertexResponseFunction(pair.getLeft(), this.graph));
}
Also used : Vertex(com.alibaba.maxgraph.structure.Vertex) GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) VertexResponseFunction(com.alibaba.maxgraph.iterator.function.VertexResponseFunction) IteratorList(com.alibaba.maxgraph.iterator.IteratorList)

Example 2 with VertexResponseFunction

use of com.alibaba.maxgraph.iterator.function.VertexResponseFunction in project GraphScope by alibaba.

the class RemoteProxy method getVertexBlock.

private Iterator<Vertex> getVertexBlock(Set<ElementId> ids) {
    StoreApi.GetVertexsRequest.Builder b = StoreApi.GetVertexsRequest.newBuilder();
    b.addAllIds(ids.stream().map(ElementId::id).collect(Collectors.toSet())).setSnapshotId(schemaFetcher.getSchemaSnapshotPair().getRight());
    Iterator<VertexResponse> responses = stub.withDeadlineAfter(timeout, TimeUnit.SECONDS).getVertexs(b.build());
    List<Iterator<VertexResponse>> responseList = Lists.newArrayList();
    responseList.add(responses);
    return new IteratorList<>(responseList, new VertexResponseFunction(schemaFetcher.getSchemaSnapshotPair().getLeft(), this.graph));
}
Also used : VertexResponseFunction(com.alibaba.maxgraph.iterator.function.VertexResponseFunction) IteratorList(com.alibaba.maxgraph.iterator.IteratorList)

Aggregations

IteratorList (com.alibaba.maxgraph.iterator.IteratorList)2 VertexResponseFunction (com.alibaba.maxgraph.iterator.function.VertexResponseFunction)2 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 Vertex (com.alibaba.maxgraph.structure.Vertex)1