You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "dosubot[bot] (via GitHub)" <gi...@apache.org> on 2024/08/06 09:06:44 UTC

Re: [I] Vertex.property后,通过g.V().out()或g.V().outE().has('', ).inV().limit(10000)查询多次返回数据不一致 [incubator-hugegraph]

dosubot[bot] commented on issue #2621:
URL: https://github.com/apache/incubator-hugegraph/issues/2621#issuecomment-2270772392

   <!-- Answer -->
   The inconsistency in the property updates on a vertex using `sourceVertex.property("balancer", balancer)` and subsequent Gremlin queries can be due to the caching mechanism and the way properties are loaded and updated in HugeGraph. To ensure that the "balancer" property is reliably updated and queried, follow these steps:
   
   1. **Update the Property within a Transaction Context**:
      Ensure that the property update is committed within a transaction.
   
      ```java
      GraphTransaction tx = graph.tx();
      try {
          sourceVertex.property("balancer", balancer);
          tx.commit();
      } catch (Exception e) {
          tx.rollback();
          throw e;
      }
      ```
   
   2. **Ensure Properties are Properly Loaded Before Querying**:
      Make sure the properties are loaded before performing the query.
   
      ```java
      sourceVertex.ensureFilledProperties(true);
      Iterator<VertexProperty<Object>> properties = sourceVertex.properties("balancer");
      while (properties.hasNext()) {
          VertexProperty<Object> property = properties.next();
          System.out.println("Balancer: " + property.value());
      }
      ```
   
   By following these steps, you can ensure that the "balancer" property is reliably updated and queried in HugeGraph <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeVertex.java)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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-unsubscribe@hugegraph.apache.org

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


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