javeme commented on code in PR #2055:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2055#discussion_r1055483658


##########
hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQueryFlatten.java:
##########
@@ -251,6 +251,28 @@ private static ConditionQuery 
newQueryFromRelations(ConditionQuery query,
         return cq;
     }
 
+    private static List<ConditionQuery> flattenRelations(ConditionQuery query) 
{
+        Relations relations = new Relations();
+        List<Condition> nonRelations = new ArrayList<>();
+        for (Condition condition : query.conditions()) {
+            if (condition.isRelation()) {
+                relations.add((Relation) condition);
+            } else {
+                nonRelations.add(condition);
+            }
+        }
+        relations = optimizeRelations(relations);
+        List<ConditionQuery> conditionQueries = new ArrayList<>();
+        if (relations != null) {
+            ConditionQuery cq = newQueryFromRelations(query, relations);
+            cq.query(nonRelations);
+            conditionQueries.add(cq);
+            return conditionQueries;
+        }
+        conditionQueries.add(query);
+        return conditionQueries;

Review Comment:
   try the following style?
   ```java
   ConditionQuery cq;
   if (relations != null) {
       cq = newQueryFromRelations(query, relations);
       cq.query(nonRelations);
   } else {
       cq = query;
   }
   return ImmutableList.of(cq);
   ```



##########
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeGraphStep.java:
##########
@@ -72,6 +72,10 @@ public HugeGraphStep(final GraphStep<S, E> originGraphStep) {
     }
 
     protected long count() {
+        if (this.ids == null) {
+            return 0;

Review Comment:
   0L



##########
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStepStrategy.java:
##########
@@ -104,6 +104,7 @@ public void apply(Traversal.Admin<?, ?> traversal) {
         graphStep.queryInfo().aggregate(Aggregate.AggregateFunc.COUNT, null);
         HugeCountStep<?> countStep = new HugeCountStep<>(traversal, graphStep);
         for (Step<?, ?> origin : originSteps) {
+            TraversalHelper.copyLabels(origin, countStep, false);

Review Comment:
   is there a replaceStep method that contains a copyLabels call? otherwise add 
some comments for why?



-- 
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]

Reply via email to