Skip to content

Commit

Permalink
add eid to client
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuan0322 authored and sighingnow committed Sep 21, 2023
1 parent c26932a commit 47f248b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ private void modifyEdge(
submit(requests, callback);
}

private long modifyVerticesAndEdge(List<Vertex> vertices, List<Edge> edges, WriteTypePb writeType) {
private long modifyVerticesAndEdge(
List<Vertex> vertices, List<Edge> edges, WriteTypePb writeType) {
List<WriteRequestPb> requests = getVertexWriteRequestPbs(vertices, writeType);
requests.addAll(getEdgeWriteRequestPbs(edges, writeType));
return submit(requests);
}

private void modifyVerticesAndEdge(List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback, WriteTypePb writeType) {
private void modifyVerticesAndEdge(
List<Vertex> vertices,
List<Edge> edges,
StreamObserver<BatchWriteResponse> callback,
WriteTypePb writeType) {
List<WriteRequestPb> requests = getVertexWriteRequestPbs(vertices, writeType);
requests.addAll(getEdgeWriteRequestPbs(edges, writeType));
submit(requests, callback);
Expand All @@ -153,15 +158,18 @@ public long deleteVerticesAndEdges(List<Vertex> vertices, List<Edge> edges) {
return modifyVerticesAndEdge(vertices, edges, WriteTypePb.DELETE);
}

public void addVerticesAndEdges(List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
public void addVerticesAndEdges(
List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
modifyVerticesAndEdge(vertices, edges, callback, WriteTypePb.INSERT);
}

public void updateVerticesAndEdges(List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
public void updateVerticesAndEdges(
List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
modifyVerticesAndEdge(vertices, edges, callback, WriteTypePb.UPDATE);
}

public void deleteVerticesAndEdges(List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
public void deleteVerticesAndEdges(
List<Vertex> vertices, List<Edge> edges, StreamObserver<BatchWriteResponse> callback) {
modifyVerticesAndEdge(vertices, edges, callback, WriteTypePb.DELETE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class Edge {
public Map<String, String> dstPk;
public Map<String, String> properties;

public long eid;

/**
* Construct an edge
* @param label edge label
Expand Down Expand Up @@ -59,6 +61,10 @@ public Edge(String label, Vertex src, Vertex dst) {
this(label, src, dst, null);
}

public void setEid(long eid) {
this.eid = eid;
}

public String getLabel() {
return label;
}
Expand Down Expand Up @@ -88,6 +94,7 @@ public EdgeRecordKeyPb toEdgeRecordKey() {
.setLabel(label)
.setSrcVertexKey(toVertexRecordKey(srcLabel, srcPk))
.setDstVertexKey(toVertexRecordKey(dstLabel, dstPk))
.setInnerId(eid)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ private void addUpdateEdgeOperation(
OperationBatch.Builder batchBuilder, GraphSchema schema, DataRecord dataRecord) {
EdgeId edgeId = getEdgeId(schema, dataRecord, false);
if (edgeId.id == 0) {
// This is for update edge, if edgeInnerId is 0, generate new id, incase there isn't such a edge
edgeId.id = edgeIdGenerator.getNextId();
// This is for update edge, if edgeInnerId is 0, generate new id, incase there isn't
// such a edge
edgeId.id = edgeIdGenerator.getNextId();
}
EdgeKind edgeKind = getEdgeKind(schema, dataRecord);
GraphElement edgeDef = schema.getElement(edgeKind.getEdgeLabelId().getId());
Expand Down

0 comments on commit 47f248b

Please sign in to comment.