imbajin commented on code in PR #2859:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2859#discussion_r2313278849


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java:
##########
@@ -775,40 +784,103 @@ protected Iterator<Vertex> queryVerticesByIds(Object[] 
vertexIds, boolean adjace
         return this.queryVerticesByIds(vertexIds, adjacentVertex, 
checkMustExist, HugeType.VERTEX);
     }
 
+    @Watched(prefix = "graph")
     protected Iterator<Vertex> queryVerticesByIds(Object[] vertexIds, boolean 
adjacentVertex,
                                                   boolean checkMustExist, 
HugeType type) {
         Query.checkForceCapacity(vertexIds.length);
 
-        // NOTE: allowed duplicated vertices if query by duplicated ids
-        List<Id> ids = InsertionOrderUtil.newList();
-        Map<Id, HugeVertex> vertices = new HashMap<>(vertexIds.length);
+        List<Id> ids;
+        Map<Id, HugeVertex> vertices;
+        boolean verticesUpdated = this.verticesInTxSize() > 0;
 
-        IdQuery query = new IdQuery(type);
-        for (Object vertexId : vertexIds) {
-            HugeVertex vertex;
-            Id id = HugeVertex.getIdValue(vertexId);
-            if (id == null || this.removedVertices.containsKey(id)) {
-                // The record has been deleted
-                continue;
-            } else if ((vertex = this.addedVertices.get(id)) != null ||
-                       (vertex = this.updatedVertices.get(id)) != null) {
-                if (vertex.expired()) {
-                    continue;
+        if (vertexIds.length == 1) {
+            Id id = HugeVertex.getIdValue(vertexIds[0]);
+

Review Comment:
   The multiple boolean flags (`tryQueryBackend`, `foundLocal`) make the 
control flow complex. Consider refactoring into a more readable structure:
   
   ```java
   private QueryResult<HugeVertex> querySingleVertex(Id id, HugeType type) {
       if (id == null) {
           return QueryResult.empty();
       }
       
       HugeVertex localVertex = findVertexInLocalTx(id);
       if (localVertex != null) {
           return QueryResult.fromLocal(localVertex);
       }
       
       if (isRemovedFromTx(id)) {
           return QueryResult.empty();
       }
       
       return QueryResult.fromBackend(queryBackendVertex(id, type));
   }
   ```
   
   This would eliminate the complex flag management and make the logic clearer.



-- 
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: issues-unsubscr...@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org
For additional commands, e-mail: issues-h...@hugegraph.apache.org

Reply via email to