Search in sources :

Example 1 with WriteStoreRequest

use of com.alibaba.maxgraph.proto.groot.WriteStoreRequest in project GraphScope by alibaba.

the class StoreWriteClient method writeStore.

public void writeStore(List<StoreDataBatch> storeDataBatches, CompletionCallback<Integer> callback) {
    Builder builder = WriteStoreRequest.newBuilder();
    for (StoreDataBatch storeDataBatch : storeDataBatches) {
        builder.addDataBatches(storeDataBatch.toProto());
    }
    WriteStoreRequest req = builder.build();
    stub.writeStore(req, new StreamObserver<WriteStoreResponse>() {

        @Override
        public void onNext(WriteStoreResponse writeStoreResponse) {
            boolean success = writeStoreResponse.getSuccess();
            if (success) {
                callback.onCompleted(req.getSerializedSize());
            } else {
                onError(new RuntimeException("store buffer is full"));
            }
        }

        @Override
        public void onError(Throwable throwable) {
            callback.onError(throwable);
        }

        @Override
        public void onCompleted() {
        }
    });
}
Also used : WriteStoreResponse(com.alibaba.maxgraph.proto.groot.WriteStoreResponse) WriteStoreRequest(com.alibaba.maxgraph.proto.groot.WriteStoreRequest) Builder(com.alibaba.maxgraph.proto.groot.WriteStoreRequest.Builder) StoreDataBatch(com.alibaba.graphscope.groot.operation.StoreDataBatch)

Aggregations

StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)1 WriteStoreRequest (com.alibaba.maxgraph.proto.groot.WriteStoreRequest)1 Builder (com.alibaba.maxgraph.proto.groot.WriteStoreRequest.Builder)1 WriteStoreResponse (com.alibaba.maxgraph.proto.groot.WriteStoreResponse)1