Search in sources :

Example 1 with WriteTypePb

use of com.alibaba.graphscope.proto.write.WriteTypePb in project GraphScope by alibaba.

the class WriteRequest method parseProto.

public static WriteRequest parseProto(WriteRequestPb proto) {
    WriteTypePb writeTypePb = proto.getWriteType();
    DataRecordPb dataRecordPb = proto.getDataRecord();
    Map<String, Object> properties = Collections.unmodifiableMap(dataRecordPb.getPropertiesMap());
    DataRecordPb.RecordKeyCase recordKeyCase = dataRecordPb.getRecordKeyCase();
    switch(recordKeyCase) {
        case VERTEX_RECORD_KEY:
            VertexRecordKey vertexRecordKey = VertexRecordKey.parseProto(dataRecordPb.getVertexRecordKey());
            return buildWriteVertexRequest(writeTypePb, new DataRecord(vertexRecordKey, properties));
        case EDGE_RECORD_KEY:
            EdgeRecordKey edgeRecordKey = EdgeRecordKey.parseProto(dataRecordPb.getEdgeRecordKey());
            return buildWriteEdgeRequest(writeTypePb, new DataRecord(edgeRecordKey, properties));
        default:
            throw new IllegalArgumentException("Invalid record key case [" + recordKeyCase + "]");
    }
}
Also used : VertexRecordKey(com.alibaba.maxgraph.sdkcommon.common.VertexRecordKey) DataRecordPb(com.alibaba.graphscope.proto.write.DataRecordPb) WriteTypePb(com.alibaba.graphscope.proto.write.WriteTypePb) EdgeRecordKey(com.alibaba.maxgraph.sdkcommon.common.EdgeRecordKey)

Aggregations

DataRecordPb (com.alibaba.graphscope.proto.write.DataRecordPb)1 WriteTypePb (com.alibaba.graphscope.proto.write.WriteTypePb)1 EdgeRecordKey (com.alibaba.maxgraph.sdkcommon.common.EdgeRecordKey)1 VertexRecordKey (com.alibaba.maxgraph.sdkcommon.common.VertexRecordKey)1