Skip to content

Commit

Permalink
[ISSUE-181] Minor fix for dsl traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
Leomrlin authored Sep 26, 2023
1 parent 3fd5f64 commit c56bdb4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void checkFields() {
if (fieldNames.size() != super.getFields().size()) {
throw new GeaFlowDSLException("Duplicate field has found in vertex table: " + getName());
}
if (!fieldNames.contains(idField.toLowerCase())) {
if (!fieldNames.contains(idField)) {
throw new GeaFlowDSLException("id field:'" + idField + "' is not found in the fields: " + fieldNames);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public int getIterationCount(int currentDepth, StepOperator stepOperator) {
maxSubDagIteration = subDagIterationCount;
}
}
currentDepth += addIteration(currentDepth, maxSubDagIteration);
currentDepth = addIteration(currentDepth, maxSubDagIteration);

if (stepOperator instanceof StepLoopUntilOperator) {
StepLoopUntilOperator loopUntilOperator = (StepLoopUntilOperator)stepOperator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
import com.antgroup.geaflow.dsl.common.data.RowEdge;
import com.antgroup.geaflow.dsl.common.data.RowVertex;
import com.antgroup.geaflow.dsl.common.data.StepRecord;
import com.antgroup.geaflow.dsl.common.data.VirtualId;
import com.antgroup.geaflow.dsl.runtime.function.graph.StepBoolFunction;
import com.antgroup.geaflow.dsl.runtime.traversal.TraversalRuntimeContext;
import com.antgroup.geaflow.dsl.runtime.traversal.collector.StepCollector;
import com.antgroup.geaflow.dsl.runtime.traversal.collector.StepJumpCollector;
import com.antgroup.geaflow.dsl.runtime.traversal.data.EndOfData;
import com.antgroup.geaflow.dsl.runtime.traversal.data.IdOnlyVertex;
import com.antgroup.geaflow.dsl.runtime.traversal.data.StepRecordWithPath;
import com.antgroup.geaflow.dsl.runtime.traversal.data.VertexRecord;
import com.antgroup.geaflow.dsl.runtime.traversal.path.ITreePath;
import com.antgroup.geaflow.state.pushdown.filter.EmptyFilter;
import java.util.List;

public class StepLoopUntilOperator extends AbstractStepOperator<StepBoolFunction,
Expand Down Expand Up @@ -88,8 +91,17 @@ protected void processRecord(StepRecordWithPath record) {
}

private StepRecordWithPath selectLastLoopPath(StepRecordWithPath record, boolean fromZeroLoop) {
RowVertex vertexRecord = ((VertexRecord)record).getTreePath().getVertex();
RowVertex vertexId = ((VertexRecord)record).getVertex();
if (fromZeroLoop) {
final RowVertex vertexRecord;
if (vertexId instanceof IdOnlyVertex && !(vertexId.getId() instanceof VirtualId)) {
vertexRecord = context.loadVertex(vertexId.getId(),
EmptyFilter.of(),
graphSchema,
addingVertexFieldTypes);
} else {
vertexRecord = vertexId;
}
return record.mapTreePath(treePath -> {
ITreePath newTreePath = treePath;
for (int i = 0; i < loopBodyPathFieldCount - 1; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public StepNodeFilterOperator(long id, StepNodeFilterFunction function) {

@Override
protected void processRecord(VertexRecord record) {
if (function.filter(record.getTreePath().getVertex())) {
if (function.filter(record.getVertex())) {
collect(record);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,14 @@ protected ITreePath filter(PathFilterFunction filterFunction,
}
filterTrees.add(edgeTreePath);
}
} else if (parentSize == 1) {
ITreePath filterTree = ((AbstractTreePath) getParents().get(0)).filter(filterFunction,
refPathIndices, fieldMapping, currentPath, maxDepth, pathId);
if (!filterTree.isEmpty()) {
filterTrees.add(filterTree.extendTo(edge));
} else if (parentSize >= 1) {
for (ITreePath parent : getParents()) {
ITreePath filterTree = ((AbstractTreePath) parent).filter(filterFunction,
refPathIndices, fieldMapping, currentPath, maxDepth, pathId);
if (!filterTree.isEmpty()) {
filterTrees.add(filterTree.extendTo(edge));
}
}
} else {
throw new IllegalArgumentException("Edge node should have only one parent,"
+ " current is: " + parentSize);
}
currentPath.remove(currentPath.size() - 1);
}
Expand Down

0 comments on commit c56bdb4

Please sign in to comment.