imbajin commented on code in PR #2859:
URL: https://github.com/apache/hugegraph/pull/2859#discussion_r4274574823
##########
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]);
+
+ boolean tryQueryBackend = true;
+ if (id == null) {
+ tryQueryBackend = false;
+ ids = ImmutableList.of();
+ } else {
+ ids = ImmutableList.of(id);
+ }
+
+ HugeVertex vertex = null;
+ if (id != null && verticesUpdated) {
+ if (this.removedVertices.containsKey(id)) {
+ // The record has been deleted
+ tryQueryBackend = false;
+ } else if ((vertex = this.addedVertices.get(id)) != null ||
+ (vertex = this.updatedVertices.get(id)) != null) {
+ // Found from local tx
+ tryQueryBackend = false;
+ if (vertex.expired()) {
+ vertex = null;
Review Comment:
[P2] Skip locally removed or expired IDs in the single-ID path
This branch suppresses the backend read but leaves ids=[id]. The final
adjacent-vertex mapper then creates an undefined vertex with default existence
checking, or throws NotFoundException with checking enabled. The original and
current multi-ID paths skip these locally suppressed IDs entirely.
This is reachable through StandardHugeGraph.adjacentVertex(id), including
filling a previously obtained lazy adjacent vertex after local removal/expiry.
A fresh traversal may filter removed incident edges first, so it does not
affect every out() query. A Java 17 differential probe of the unchanged method
bodies with reduced collaborators confirms baseSingle=[] and headMulti=[],
versus headSingle=[UNDEFINED]/NotFoundException; live and genuinely missing
controls retain their behavior.
Please return an empty iterator or ID sequence for the locally
removed/expired cases while preserving genuinely missing-backend behavior. This
was a focused method probe, not full graph integration.
--
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]