Thespica commented on code in PR #727:
URL: https://github.com/apache/incubator-graphar/pull/727#discussion_r2272317992


##########
maven-projects/info/src/main/java/org/apache/graphar/info/GraphInfo.java:
##########
@@ -94,121 +167,134 @@ public Optional<GraphInfo> addVertexAsNew(VertexInfo 
vertexInfo) {
         if (vertexInfo == null || hasVertexInfo(vertexInfo.getType())) {
             return Optional.empty();
         }
-        final org.apache.graphar.proto.GraphInfo newProtoGraphInfo =
-                org.apache.graphar.proto.GraphInfo.newBuilder(protoGraphInfo)
-                        .addVertices(vertexInfo.getVertexPath())
-                        .build();
-        final List<VertexInfo> newVertexInfoList =
-                Stream.concat(cachedVertexInfoList.stream(), 
Stream.of(vertexInfo))
+        List<VertexInfo> newVertexInfos =
+                Stream.concat(vertexInfos.stream(), Stream.of(vertexInfo))
                         .collect(Collectors.toList());
-        final Map<String, VertexInfo> newVertexInfoMap =
+        Map<String, VertexInfo> newVertexType2VertexInfo =
                 Stream.concat(
-                                cachedVertexInfoMap.entrySet().stream(),
+                                vertexType2VertexInfo.entrySet().stream(),
                                 Stream.of(Map.entry(vertexInfo.getType(), 
vertexInfo)))
                         .collect(
                                 Collectors.toUnmodifiableMap(
                                         Map.Entry::getKey, 
Map.Entry::getValue));
         return Optional.of(
                 new GraphInfo(
-                        newProtoGraphInfo,
-                        newVertexInfoList,
-                        cachedEdgeInfoList,
-                        newVertexInfoMap,
-                        cachedEdgeInfoMap));
+                        name,
+                        newVertexInfos,
+                        edgeInfos,
+                        prefix,
+                        version,
+                        newVertexType2VertexInfo,
+                        edgeConcat2EdgeInfo));
     }
 
     public Optional<GraphInfo> addEdgeAsNew(EdgeInfo edgeInfo) {
         if (edgeInfo == null
                 || hasEdgeInfo(
-                        edgeInfo.getSrcLabel(), edgeInfo.getEdgeLabel(), 
edgeInfo.getDstLabel())) {
+                        edgeInfo.getSrcType(), edgeInfo.getEdgeType(), 
edgeInfo.getDstType())) {
             return Optional.empty();
         }
-        final org.apache.graphar.proto.GraphInfo newProtoGraphInfo =
-                org.apache.graphar.proto.GraphInfo.newBuilder(protoGraphInfo)
-                        .addEdges(edgeInfo.getEdgePath())
-                        .build();
-        final List<EdgeInfo> newEdgeInfos =
-                Stream.concat(cachedEdgeInfoList.stream(), Stream.of(edgeInfo))
-                        .collect(Collectors.toList());
-        final Map<String, EdgeInfo> newEdgeConcat2EdgeInfo =
+        List<EdgeInfo> newEdgeInfos =
+                Stream.concat(edgeInfos.stream(), 
Stream.of(edgeInfo)).collect(Collectors.toList());
+        Map<String, EdgeInfo> newEdgeConcat2EdgeInfo =
                 Stream.concat(
-                                cachedEdgeInfoMap.entrySet().stream(),
+                                edgeConcat2EdgeInfo.entrySet().stream(),
                                 Stream.of(Map.entry(edgeInfo.getConcat(), 
edgeInfo)))
                         .collect(
                                 Collectors.toUnmodifiableMap(
                                         Map.Entry::getKey, 
Map.Entry::getValue));
         return Optional.of(
                 new GraphInfo(
-                        newProtoGraphInfo,
-                        cachedVertexInfoList,
+                        name,
+                        vertexInfos,
                         newEdgeInfos,
-                        cachedVertexInfoMap,
+                        prefix,
+                        version,
+                        vertexType2VertexInfo,
                         newEdgeConcat2EdgeInfo));
     }
 
-    public boolean hasVertexInfo(String label) {
-        return cachedVertexInfoMap.containsKey(label);
+    public boolean hasVertexInfo(String type) {
+        return vertexType2VertexInfo.containsKey(type);
     }
 
-    public boolean hasEdgeInfo(String srcLabel, String edgeLabel, String 
dstLabel) {
-        return cachedEdgeInfoMap.containsKey(EdgeInfo.concat(srcLabel, 
edgeLabel, dstLabel));
+    public boolean hasEdgeInfo(String srcType, String edgeType, String 
dstType) {
+        return edgeConcat2EdgeInfo.containsKey(srcType + dstType + edgeType);
     }
 
-    public VertexInfo getVertexInfo(String label) {
-        checkVertexExist(label);
-        return cachedVertexInfoMap.get(label);
+    public VertexInfo getVertexInfo(String type) {
+        checkVertexExist(type);
+        return vertexType2VertexInfo.get(type);
     }
 
-    public EdgeInfo getEdgeInfo(String srcLabel, String edgeLabel, String 
dstLabel) {
-        checkEdgeExist(srcLabel, edgeLabel, dstLabel);
-        return cachedEdgeInfoMap.get(EdgeInfo.concat(srcLabel, edgeLabel, 
dstLabel));
+    public EdgeInfo getEdgeInfo(String srcType, String edgeType, String 
dstType) {
+        checkEdgeExist(srcType, edgeType, dstType);
+        return edgeConcat2EdgeInfo.get(srcType + edgeType + dstType);
     }
 

Review Comment:
   do it too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to