use of com.alibaba.graphscope.groot.operation.OperationType in project GraphScope by alibaba.
the class GraphWriter method writeBatch.
public void writeBatch(String requestId, String writeSession, List<WriteRequest> writeRequests, CompletionCallback<Long> callback) {
this.pendingWriteCount.incrementAndGet();
GraphSchema schema = snapshotCache.getSnapshotWithSchema().getGraphDef();
OperationBatch.Builder batchBuilder = OperationBatch.newBuilder();
for (WriteRequest writeRequest : writeRequests) {
OperationType operationType = writeRequest.getOperationType();
DataRecord dataRecord = writeRequest.getDataRecord();
switch(operationType) {
case OVERWRITE_VERTEX:
addOverwriteVertexOperation(batchBuilder, schema, dataRecord);
break;
case UPDATE_VERTEX:
addUpdateVertexOperation(batchBuilder, schema, dataRecord);
break;
case DELETE_VERTEX:
addDeleteVertexOperation(batchBuilder, schema, dataRecord);
break;
case OVERWRITE_EDGE:
addOverwriteEdgeOperation(batchBuilder, schema, dataRecord);
break;
case UPDATE_EDGE:
addUpdateEdgeOperation(batchBuilder, schema, dataRecord);
break;
case DELETE_EDGE:
addDeleteEdgeOperation(batchBuilder, schema, dataRecord);
break;
default:
throw new IllegalArgumentException("Invalid operationType [" + operationType + "]");
}
}
OperationBatch operationBatch = batchBuilder.build();
int writeQueueId = getWriteQueueId(writeSession);
int ingestorId = this.metaService.getIngestorIdForQueue(writeQueueId);
long startTimeNano = System.nanoTime();
this.ingestWriteClients.getClient(ingestorId).writeIngestorAsync(requestId, writeQueueId, operationBatch, new CompletionCallback<Long>() {
@Override
public void onCompleted(Long res) {
long writeSnapshotId = res;
lastWrittenSnapshotId.updateAndGet(x -> x < writeSnapshotId ? writeSnapshotId : x);
writeRequestsTotal.addAndGet(writeRequests.size());
finish();
callback.onCompleted(res);
}
@Override
public void onError(Throwable t) {
finish();
callback.onError(t);
}
void finish() {
long ingestorCompleteTimeNano = System.nanoTime();
ingestorBlockTimeNano.addAndGet(ingestorCompleteTimeNano - startTimeNano);
pendingWriteCount.decrementAndGet();
}
});
}
use of com.alibaba.graphscope.groot.operation.OperationType in project GraphScope by alibaba.
the class DdlExecutors method executeDdlRequestBatch.
public DdlResult executeDdlRequestBatch(DdlRequestBatch ddlRequestBatch, GraphDef graphDef, int partitionCount) throws InvalidProtocolBufferException {
List<Operation> operations = new ArrayList<>();
GraphDef tmpGraphDef = graphDef;
for (DdlRequestBlob ddlRequestBlob : ddlRequestBatch) {
OperationType operationType = ddlRequestBlob.getOperationType();
ByteString ddlBlob = ddlRequestBlob.getBytes();
DdlResult ddlResult = getExecutor(operationType).execute(ddlBlob, tmpGraphDef, partitionCount);
operations.addAll(ddlResult.getDdlOperations());
tmpGraphDef = ddlResult.getGraphDef();
}
return new DdlResult(tmpGraphDef, operations);
}
Aggregations