imbajin commented on code in PR #2859:
URL:
https://github.com/apache/incubator-hugegraph/pull/2859#discussion_r2313281416
##########
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;
Review Comment:
Consider optimizing the `verticesUpdated` check. Currently it calls
`this.verticesInTxSize() > 0` which may iterate through all transaction maps.
For single-ID queries, you could check more efficiently:
```java
// More efficient check for single ID
boolean hasLocalChanges = this.removedVertices.containsKey(id) ||
this.addedVertices.containsKey(id) ||
this.updatedVertices.containsKey(id);
```
This would be O(1) instead of potentially O(n) for the transaction size
calculation.
--
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]