Search in sources :

Example 1 with TreeNode

use of com.alibaba.maxgraph.compiler.tree.TreeNode in project GraphScope by alibaba.

the class CostUtils method buildLabelCostGraph.

private static CostGraph buildLabelCostGraph(String label, TreeNode startNode, TreeNode selectNode, CostMappingManager costMappingManager, boolean labelValueFlag) {
    CostGraph costGraph = new CostGraph(costMappingManager);
    TreeNode currNode = selectNode;
    boolean foundFirstFlag = false;
    while (currNode instanceof UnaryTreeNode) {
        if (foundFirstFlag) {
            costGraph.addFirstRow(new CostRow(Lists.newArrayList()));
            currNode = ((UnaryTreeNode) currNode).getInputNode();
            continue;
        }
        if (currNode == selectNode) {
            if (labelValueFlag) {
                costGraph.addFirstRow(new CostRow(Lists.newArrayList(new RowField(buildValueName(label)))));
            } else {
                costGraph.addFirstRow(new CostRow(Lists.newArrayList(new RowField(label))));
            }
        } else {
            List<RowField> rowFieldList = currNode.getOutputNode() == selectNode ? Lists.newArrayList(new RowField(buildValueName(label))) : buildRowFieldList(label, labelValueFlag);
            foundFirstFlag = currNode == startNode;
            costGraph.addFirstRow(new CostRow(rowFieldList, foundFirstFlag));
        }
        currNode = ((UnaryTreeNode) currNode).getInputNode();
    }
    if (!foundFirstFlag) {
        List<RowField> rowFieldList = buildRowFieldList(label, labelValueFlag);
        costGraph.addFirstRow(new CostRow(rowFieldList, true));
    } else {
        costGraph.addFirstRow(new CostRow(Lists.newArrayList()));
    }
    return costGraph;
}
Also used : SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SelectOneTreeNode(com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode) WherePredicateTreeNode(com.alibaba.maxgraph.compiler.tree.WherePredicateTreeNode) RepeatTreeNode(com.alibaba.maxgraph.compiler.tree.RepeatTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) SelectTreeNode(com.alibaba.maxgraph.compiler.tree.SelectTreeNode) TreeNode(com.alibaba.maxgraph.compiler.tree.TreeNode) UnionTreeNode(com.alibaba.maxgraph.compiler.tree.UnionTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode)

Example 2 with TreeNode

use of com.alibaba.maxgraph.compiler.tree.TreeNode in project GraphScope by alibaba.

the class CostUtils method buildCostGraph.

public static CostGraph buildCostGraph(TreeNode leafNode, TreeNodeLabelManager treeNodeLabelManager) {
    TreeNode currNode = leafNode;
    CostMappingManager costMappingManager = new CostMappingManager();
    CostGraph costGraph = new CostGraph(costMappingManager);
    CostEstimate costEstimate = new CostEstimate();
    while (currNode instanceof UnaryTreeNode) {
        if (currNode instanceof SelectTreeNode) {
            SelectTreeNode selectTreeNode = (SelectTreeNode) currNode;
            Map<String, TreeNode> labelStartNodeList = selectTreeNode.getLabelTreeNodeList();
            List<String> selectKeyList = selectTreeNode.getSelectKeyList();
            Map<String, TreeNode> labelValueNodeList = selectTreeNode.getLabelValueTreeNodeList();
            for (String label : selectKeyList) {
                TreeNode labelValueNode = labelValueNodeList.get(label);
                TreeNode labelStartNode = labelStartNodeList.get(label);
                if (labelStartNode == null) {
                    continue;
                }
                double nodeSelfComputeCost = costEstimate.estimateComputeCost(labelStartNode, labelStartNode);
                double startNodeNetworkCost = costEstimate.estimateNetworkCost(labelStartNode);
                costMappingManager.addComputeCost(Pair.of(label, label), nodeSelfComputeCost);
                costMappingManager.addValueNetworkCost(label, startNodeNetworkCost);
                if (labelValueNode != null && !(labelValueNode instanceof SourceTreeNode)) {
                    costMappingManager.addComputeTree(label, labelValueNode);
                    double nodeValueComputeCost = costEstimate.estimateComputeCost(labelStartNode, labelValueNode);
                    double nodeValueNetworkCost = costEstimate.estimateNetworkCost(labelValueNode);
                    String labelValueTag = CostUtils.buildValueName(label);
                    costMappingManager.addValueParent(labelValueTag, label);
                    costMappingManager.addComputeCost(Pair.of(label, labelValueTag), nodeValueComputeCost);
                    costMappingManager.addValueNetworkCost(labelValueTag, nodeValueNetworkCost);
                }
                CostGraph currGraph = buildLabelCostGraph(label, labelStartNode, currNode, costMappingManager, labelValueNode != null && !(labelValueNode instanceof SourceTreeNode));
                costGraph.mergeCostGraph(currGraph);
            }
        } else if (currNode instanceof SelectOneTreeNode) {
            SelectOneTreeNode selectOneTreeNode = (SelectOneTreeNode) currNode;
            String label = selectOneTreeNode.getSelectLabel();
            TreeNode labelStartNode = selectOneTreeNode.getLabelStartTreeNode();
            TreeNode labelValueNode = selectOneTreeNode.getTraversalTreeNode();
            if (null == labelStartNode || null == labelValueNode) {
                break;
            }
            double nodeSelfComputeCost = costEstimate.estimateComputeCost(labelStartNode, labelStartNode);
            double startNodeNetworkCost = costEstimate.estimateNetworkCost(labelStartNode);
            costMappingManager.addComputeCost(Pair.of(label, label), nodeSelfComputeCost);
            costMappingManager.addValueNetworkCost(label, startNodeNetworkCost);
            if (labelValueNode != null && !(labelValueNode instanceof SourceTreeNode)) {
                costMappingManager.addComputeTree(label, labelValueNode);
                double nodeValueComputeCost = costEstimate.estimateComputeCost(labelStartNode, labelValueNode);
                double nodeValueNetworkCost = costEstimate.estimateNetworkCost(labelValueNode);
                String labelValueTag = CostUtils.buildValueName(label);
                costMappingManager.addValueParent(labelValueTag, label);
                costMappingManager.addComputeCost(Pair.of(label, labelValueTag), nodeValueComputeCost);
                costMappingManager.addValueNetworkCost(labelValueTag, nodeValueNetworkCost);
            }
            CostGraph currGraph = buildLabelCostGraph(label, labelStartNode, currNode, costMappingManager, labelValueNode != null && !(labelValueNode instanceof SourceTreeNode));
            costGraph.mergeCostGraph(currGraph);
        } else if (currNode instanceof WherePredicateTreeNode) {
            WherePredicateTreeNode wherePredicateTreeNode = (WherePredicateTreeNode) currNode;
            String startKey = wherePredicateTreeNode.getStartKey();
            if (StringUtils.isNotEmpty(startKey)) {
                CostGraph startKeyGraph = buildLabelCostGraph(wherePredicateTreeNode.getStartKey(), treeNodeLabelManager.getLastTreeNode(wherePredicateTreeNode.getStartKey()), currNode, costMappingManager, false);
                costGraph.mergeCostGraph(startKeyGraph);
            }
            String predicateValue = wherePredicateTreeNode.getPredicateValue();
            if (StringUtils.isNotEmpty(predicateValue)) {
                List<TreeNode> labelNodeList = treeNodeLabelManager.getLabelTreeNodeList(predicateValue);
                if (null != labelNodeList) {
                    TreeNode predicateNode = labelNodeList.get(labelNodeList.size() - 1);
                    if (null != predicateNode) {
                        CostGraph predicateGraph = buildLabelCostGraph(predicateValue, predicateNode, currNode, costMappingManager, false);
                        costGraph.mergeCostGraph(predicateGraph);
                    }
                }
            }
        } else if (currNode instanceof RepeatTreeNode || currNode instanceof UnionTreeNode) {
            costGraph.clear();
            return costGraph;
        }
        currNode = ((UnaryTreeNode) currNode).getInputNode();
    }
    return costGraph;
}
Also used : WherePredicateTreeNode(com.alibaba.maxgraph.compiler.tree.WherePredicateTreeNode) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) RepeatTreeNode(com.alibaba.maxgraph.compiler.tree.RepeatTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) UnionTreeNode(com.alibaba.maxgraph.compiler.tree.UnionTreeNode) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SelectOneTreeNode(com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode) WherePredicateTreeNode(com.alibaba.maxgraph.compiler.tree.WherePredicateTreeNode) RepeatTreeNode(com.alibaba.maxgraph.compiler.tree.RepeatTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) SelectTreeNode(com.alibaba.maxgraph.compiler.tree.SelectTreeNode) TreeNode(com.alibaba.maxgraph.compiler.tree.TreeNode) UnionTreeNode(com.alibaba.maxgraph.compiler.tree.UnionTreeNode) SelectOneTreeNode(com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode) SelectTreeNode(com.alibaba.maxgraph.compiler.tree.SelectTreeNode)

Example 3 with TreeNode

use of com.alibaba.maxgraph.compiler.tree.TreeNode in project GraphScope by alibaba.

the class NodeLabelList method buildNodeLabel.

/**
 * Build label list of current node from parent node, tree node and schema
 *
 * @param parentNodeLabel The given parent node
 * @param treeNode        The given tree node
 * @param graphSchema     The given graph schema
 * @return The result node label list
 */
public static NodeLabelList buildNodeLabel(NodeLabelList parentNodeLabel, TreeNode treeNode, GraphSchema graphSchema) {
    NodeLabelList nodeLabelList = new NodeLabelList();
    if (null == parentNodeLabel) {
        BaseTreeNode baseTreeNode = (BaseTreeNode) treeNode;
        final Set<String> labelList = Sets.newHashSet();
        baseTreeNode.getHasContainerList().forEach(v -> {
            if (StringUtils.equals(v.getKey(), T.label.getAccessor())) {
                if (v.getBiPredicate() instanceof Compare && v.getBiPredicate() == Compare.eq) {
                    labelList.add(v.getValue().toString());
                } else if (v.getBiPredicate() instanceof Contains && v.getBiPredicate() == Contains.within) {
                    List<String> labelValueList = (List<String>) v.getValue();
                    labelList.addAll(labelValueList);
                } else {
                    throw new IllegalArgumentException("Not support label compare " + v.toString());
                }
            }
        });
        if (treeNode instanceof SourceVertexTreeNode) {
            List<String> vertexLabelList = graphSchema.getVertexList().stream().map(GraphElement::getLabel).collect(Collectors.toList());
            Set<String> resultLabelList;
            if (labelList.isEmpty()) {
                resultLabelList = Sets.newHashSet(vertexLabelList);
            } else {
                resultLabelList = labelList.stream().filter(vertexLabelList::contains).collect(Collectors.toSet());
            }
            nodeLabelList.addVertexLabel(resultLabelList);
        } else if (treeNode instanceof SourceEdgeTreeNode) {
            List<String> edgeLabelList = graphSchema.getEdgeList().stream().map(GraphElement::getLabel).collect(Collectors.toList());
            Set<String> resultLabelList;
            if (labelList.isEmpty()) {
                resultLabelList = Sets.newHashSet(edgeLabelList);
            } else {
                resultLabelList = labelList.stream().filter(edgeLabelList::contains).collect(Collectors.toSet());
            }
            nodeLabelList.addEdgeLabel(resultLabelList);
        } else {
            nodeLabelList.enableUnknown();
        }
    } else {
        Set<String> parentVertexLabelList = Sets.newHashSet();
        Set<String> parentEdgeLabelList = Sets.newHashSet();
        if (parentNodeLabel.isUnknownFlag()) {
            parentVertexLabelList.addAll(graphSchema.getVertexList().stream().map(GraphElement::getLabel).collect(Collectors.toList()));
            parentEdgeLabelList.addAll(graphSchema.getEdgeList().stream().map(GraphElement::getLabel).collect(Collectors.toList()));
        } else {
            parentVertexLabelList.addAll(parentNodeLabel.getVertexLabelList());
            parentEdgeLabelList.addAll(parentNodeLabel.getEdgeLabelList());
        }
        if (treeNode instanceof VertexTreeNode) {
            VertexTreeNode vertexTreeNode = (VertexTreeNode) treeNode;
            Direction direction = vertexTreeNode.getDirection();
            nodeLabelList.addVertexLabel(computeVertexLabelList(parentVertexLabelList, direction, vertexTreeNode.getEdgeLabels(), graphSchema));
        } else if (treeNode instanceof EdgeTreeNode) {
            EdgeTreeNode edgeTreeNode = (EdgeTreeNode) treeNode;
            Direction direction = edgeTreeNode.getDirection();
            nodeLabelList.addEdgeLabel(computeEdgeLabelList(parentVertexLabelList, direction, edgeTreeNode.getEdgeLabels(), graphSchema));
        } else if (treeNode instanceof EdgeVertexTreeNode) {
            EdgeVertexTreeNode edgeVertexTreeNode = (EdgeVertexTreeNode) treeNode;
            Map<String, Pair<Set<String>, Set<String>>> edgeSourceTargetPairList = getEdgeSourceTargetPairList(parentEdgeLabelList.toArray(new String[0]), graphSchema);
            Direction direction = edgeVertexTreeNode.getDirection();
            edgeSourceTargetPairList.forEach((key, value) -> {
                switch(direction) {
                    case OUT:
                        {
                            nodeLabelList.addVertexLabel(value.getLeft());
                            break;
                        }
                    case IN:
                        {
                            nodeLabelList.addVertexLabel(value.getRight());
                            break;
                        }
                    case BOTH:
                        {
                            nodeLabelList.addVertexLabel(value.getLeft());
                            nodeLabelList.addVertexLabel(value.getRight());
                            break;
                        }
                }
            });
        } else if (treeNode instanceof EdgeOtherVertexTreeNode) {
            Map<String, Pair<Set<String>, Set<String>>> edgeSourceTargetPairList = getEdgeSourceTargetPairList(parentEdgeLabelList.toArray(new String[0]), graphSchema);
            edgeSourceTargetPairList.forEach((key, value) -> {
                nodeLabelList.addVertexLabel(value.getLeft());
                nodeLabelList.addVertexLabel(value.getRight());
            });
        } else {
            nodeLabelList.enableUnknown();
        }
    }
    return nodeLabelList;
}
Also used : BaseTreeNode(com.alibaba.maxgraph.compiler.tree.BaseTreeNode) GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) VertexTreeNode(com.alibaba.maxgraph.compiler.tree.VertexTreeNode) Contains(org.apache.tinkerpop.gremlin.process.traversal.Contains) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) EdgeRelation(com.alibaba.maxgraph.compiler.api.schema.EdgeRelation) Map(java.util.Map) TreeNode(com.alibaba.maxgraph.compiler.tree.TreeNode) EdgeVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeVertexTreeNode) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) MoreObjects(com.google.common.base.MoreObjects) Set(java.util.Set) EdgeTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeTreeNode) T(org.apache.tinkerpop.gremlin.structure.T) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Compare(org.apache.tinkerpop.gremlin.process.traversal.Compare) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) EdgeOtherVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeOtherVertexTreeNode) GraphElement(com.alibaba.maxgraph.compiler.api.schema.GraphElement) Set(java.util.Set) EdgeVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeVertexTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode) EdgeTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeTreeNode) Direction(org.apache.tinkerpop.gremlin.structure.Direction) VertexTreeNode(com.alibaba.maxgraph.compiler.tree.VertexTreeNode) EdgeVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeVertexTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) EdgeOtherVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeOtherVertexTreeNode) EdgeOtherVertexTreeNode(com.alibaba.maxgraph.compiler.tree.EdgeOtherVertexTreeNode) Contains(org.apache.tinkerpop.gremlin.process.traversal.Contains) GraphElement(com.alibaba.maxgraph.compiler.api.schema.GraphElement) BaseTreeNode(com.alibaba.maxgraph.compiler.tree.BaseTreeNode) Compare(org.apache.tinkerpop.gremlin.process.traversal.Compare) List(java.util.List) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with TreeNode

use of com.alibaba.maxgraph.compiler.tree.TreeNode in project GraphScope by alibaba.

the class TreeNodeUtils method buildSubQueryPlanWithKey.

/**
 * @param treeNode The given tree node
 * @param sourceVertex The source vertex
 * @param treeNodeLabelManager The given label manager
 * @param contextManager The context manager
 * @param vertexIdManager The vertex id manager
 * @return The sub query with enter key vertex
 */
public static LogicalSubQueryPlan buildSubQueryPlanWithKey(TreeNode treeNode, LogicalVertex sourceVertex, TreeNodeLabelManager treeNodeLabelManager, ContextManager contextManager, VertexIdManager vertexIdManager) {
    List<TreeNode> treeNodeList = buildTreeNodeListFromLeaf(treeNode);
    LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
    LogicalVertex currentSourceVertex = sourceVertex;
    for (TreeNode currentNode : treeNodeList) {
        if (currentNode instanceof AbstractUseKeyNode) {
            ((AbstractUseKeyNode) currentNode).enableUseKeyFlag(currentSourceVertex);
        }
        if (currentNode instanceof SourceDelegateNode) {
            LogicalVertex enterKeyVertex = new LogicalUnaryVertex(vertexIdManager.getId(), new ProcessorFunction(QueryFlowOuterClass.OperatorType.ENTER_KEY, Message.Value.newBuilder().setPayload(QueryFlowOuterClass.EnterKeyArgumentProto.newBuilder().setEnterKeyType(QueryFlowOuterClass.EnterKeyTypeProto.KEY_SELF).setUniqFlag(true).build().toByteString())), false, currentSourceVertex);
            currentNode.setFinishVertex(enterKeyVertex, treeNodeLabelManager);
            logicalSubQueryPlan.addLogicalVertex(currentSourceVertex);
            logicalSubQueryPlan.addLogicalVertex(enterKeyVertex);
            logicalSubQueryPlan.addLogicalEdge(currentSourceVertex, enterKeyVertex, new LogicalEdge());
            currentSourceVertex = enterKeyVertex;
        }
        logicalSubQueryPlan.mergeLogicalQueryPlan(currentNode.buildLogicalQueryPlan(contextManager));
    }
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) VertexTreeNode(com.alibaba.maxgraph.compiler.tree.VertexTreeNode) MaxTreeNode(com.alibaba.maxgraph.compiler.tree.MaxTreeNode) RangeGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.RangeGlobalTreeNode) FoldTreeNode(com.alibaba.maxgraph.compiler.tree.FoldTreeNode) TreeNode(com.alibaba.maxgraph.compiler.tree.TreeNode) TokenTreeNode(com.alibaba.maxgraph.compiler.tree.TokenTreeNode) MinTreeNode(com.alibaba.maxgraph.compiler.tree.MinTreeNode) CountGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode) HasTreeNode(com.alibaba.maxgraph.compiler.tree.HasTreeNode) SelectOneTreeNode(com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode) PropertyMapTreeNode(com.alibaba.maxgraph.compiler.tree.PropertyMapTreeNode) SumTreeNode(com.alibaba.maxgraph.compiler.tree.SumTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan) AbstractUseKeyNode(com.alibaba.maxgraph.compiler.tree.addition.AbstractUseKeyNode)

Example 5 with TreeNode

use of com.alibaba.maxgraph.compiler.tree.TreeNode in project GraphScope by alibaba.

the class TreeNodeUtils method optimizeSubFilterNode.

/**
 * Optimize filter node in TraversalFilterNode
 *
 * @param filterTreeNode The given filter node
 * @return The optimized filter node
 */
public static TreeNode optimizeSubFilterNode(TreeNode filterTreeNode) {
    TreeNode sourceNode = getSourceTreeNode(filterTreeNode);
    UnaryTreeNode firstNode = (UnaryTreeNode) sourceNode.getOutputNode();
    if (firstNode instanceof VertexTreeNode) {
        VertexTreeNode vertexTreeNode = (VertexTreeNode) firstNode;
        Direction direction = vertexTreeNode.getDirection();
        if (direction == Direction.OUT) {
            while (true) {
                boolean optimizeFinish = true;
                TreeNode outputNode = vertexTreeNode.getOutputNode();
                if (null == outputNode) {
                    vertexTreeNode.enableCountFlag();
                    TreeNode hasTreeNode = new HasTreeNode(vertexTreeNode, Lists.newArrayList(new HasContainer("", P.gt(0L))), vertexTreeNode.getSchema());
                    hasTreeNode.setOutputNode(null);
                    break;
                }
                if (outputNode instanceof RangeGlobalTreeNode) {
                    TreeNode rangeOutputNode = outputNode.getOutputNode();
                    vertexTreeNode.setOutputNode(rangeOutputNode);
                    if (null != rangeOutputNode) {
                        ((UnaryTreeNode) rangeOutputNode).setInputNode(vertexTreeNode);
                    }
                    optimizeFinish = false;
                } else if (outputNode instanceof CountGlobalTreeNode) {
                    vertexTreeNode.enableCountFlag();
                    TreeNode rangeOutputNode = outputNode.getOutputNode();
                    vertexTreeNode.setOutputNode(rangeOutputNode);
                    if (null != rangeOutputNode) {
                        ((UnaryTreeNode) rangeOutputNode).setInputNode(vertexTreeNode);
                    }
                    optimizeFinish = false;
                }
                if (optimizeFinish) {
                    break;
                }
            }
        }
    }
    TreeNode currentFilterNode = sourceNode;
    while (currentFilterNode.getOutputNode() != null) {
        currentFilterNode = currentFilterNode.getOutputNode();
    }
    return currentFilterNode;
}
Also used : VertexTreeNode(com.alibaba.maxgraph.compiler.tree.VertexTreeNode) HasTreeNode(com.alibaba.maxgraph.compiler.tree.HasTreeNode) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) VertexTreeNode(com.alibaba.maxgraph.compiler.tree.VertexTreeNode) MaxTreeNode(com.alibaba.maxgraph.compiler.tree.MaxTreeNode) RangeGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.RangeGlobalTreeNode) FoldTreeNode(com.alibaba.maxgraph.compiler.tree.FoldTreeNode) TreeNode(com.alibaba.maxgraph.compiler.tree.TreeNode) TokenTreeNode(com.alibaba.maxgraph.compiler.tree.TokenTreeNode) MinTreeNode(com.alibaba.maxgraph.compiler.tree.MinTreeNode) CountGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode) HasTreeNode(com.alibaba.maxgraph.compiler.tree.HasTreeNode) SelectOneTreeNode(com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode) PropertyMapTreeNode(com.alibaba.maxgraph.compiler.tree.PropertyMapTreeNode) SumTreeNode(com.alibaba.maxgraph.compiler.tree.SumTreeNode) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) CountGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode) Direction(org.apache.tinkerpop.gremlin.structure.Direction) UnaryTreeNode(com.alibaba.maxgraph.compiler.tree.UnaryTreeNode) RangeGlobalTreeNode(com.alibaba.maxgraph.compiler.tree.RangeGlobalTreeNode)

Aggregations

TreeNode (com.alibaba.maxgraph.compiler.tree.TreeNode)19 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)17 UnaryTreeNode (com.alibaba.maxgraph.compiler.tree.UnaryTreeNode)13 VertexTreeNode (com.alibaba.maxgraph.compiler.tree.VertexTreeNode)12 RangeGlobalTreeNode (com.alibaba.maxgraph.compiler.tree.RangeGlobalTreeNode)11 SelectOneTreeNode (com.alibaba.maxgraph.compiler.tree.SelectOneTreeNode)11 CountGlobalTreeNode (com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode)9 FoldTreeNode (com.alibaba.maxgraph.compiler.tree.FoldTreeNode)9 HasTreeNode (com.alibaba.maxgraph.compiler.tree.HasTreeNode)9 MaxTreeNode (com.alibaba.maxgraph.compiler.tree.MaxTreeNode)9 MinTreeNode (com.alibaba.maxgraph.compiler.tree.MinTreeNode)9 PropertyMapTreeNode (com.alibaba.maxgraph.compiler.tree.PropertyMapTreeNode)9 SumTreeNode (com.alibaba.maxgraph.compiler.tree.SumTreeNode)9 TokenTreeNode (com.alibaba.maxgraph.compiler.tree.TokenTreeNode)9 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)5 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)5 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)5 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)4 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)4 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)4