Search in sources :

Example 6 with SourceVertexTreeNode

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

the class TreeManager method optimizeOrderRange.

/**
 * Optimize order+range operator
 */
private void optimizeOrderRange() {
    TreeNode currentTreeNode = treeLeaf;
    while (!(currentTreeNode instanceof SourceTreeNode)) {
        if (currentTreeNode instanceof OrderGlobalTreeNode) {
            OrderGlobalTreeNode orderGlobalTreeNode = OrderGlobalTreeNode.class.cast(currentTreeNode);
            TreeNode orderInputNode = orderGlobalTreeNode.getInputNode();
            if (orderInputNode instanceof SourceVertexTreeNode && ((SourceVertexTreeNode) orderInputNode).getBeforeRequirementList().isEmpty() && ((SourceVertexTreeNode) orderInputNode).getAfterRequirementList().isEmpty() && orderGlobalTreeNode.isEmptyOrderNode() && !orderGlobalTreeNode.orderFlag && null != orderGlobalTreeNode.rangeLimit) {
                QueryFlowOuterClass.RangeLimit.Builder orderRangeBuilder = orderGlobalTreeNode.rangeLimit;
                orderInputNode.setRangeLimit(0, orderRangeBuilder.getRangeEnd(), true);
                ((SourceVertexTreeNode) orderInputNode).enablePartitionIdFlag();
                orderGlobalTreeNode.enablePartitionIdFlag();
            }
        }
        currentTreeNode = UnaryTreeNode.class.cast(currentTreeNode).getInputNode();
    }
}
Also used : SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)

Example 7 with SourceVertexTreeNode

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

the class TreeBuilder method visitGraphStep.

/**
 * Convert graph step to SourceTreeNode
 *
 * @param step The given GraphStep
 */
private TreeNode visitGraphStep(GraphStep step) {
    if (step instanceof MaxGraphStep) {
        Map<String, Object> queryConfig = ((MaxGraphStep) step).getQueryConfig();
        if (null != queryConfig) {
            this.queryConfig.putAll(queryConfig);
        }
    }
    Object[] ids = step.getIds();
    SourceTreeNode sourceTreeNode;
    if (step.returnsVertex()) {
        if (null == ids || ids.length == 0) {
            sourceTreeNode = new SourceVertexTreeNode(schema);
        } else {
            sourceTreeNode = new SourceVertexTreeNode(ids, schema);
        }
    } else {
        if (null == ids || ids.length == 0) {
            sourceTreeNode = new SourceEdgeTreeNode(schema);
        } else {
            sourceTreeNode = new SourceEdgeTreeNode(ids, schema);
        }
    }
    Supplier<?> supplier = step.getTraversal().getSideEffects().getSackInitialValue();
    if (null != supplier) {
        sourceTreeNode.setInitialSackValue(supplier.get());
    }
    return sourceTreeNode;
}
Also used : MaxGraphStep(com.alibaba.maxgraph.tinkerpop.steps.MaxGraphStep) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode)

Aggregations

SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)7 SourceEdgeTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode)5 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)4 EstimateCountTreeNode (com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode)2 SourceCreateGraphTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode)2 EdgeRelation (com.alibaba.maxgraph.compiler.api.schema.EdgeRelation)1 GraphElement (com.alibaba.maxgraph.compiler.api.schema.GraphElement)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)1 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)1 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)1 BaseTreeNode (com.alibaba.maxgraph.compiler.tree.BaseTreeNode)1 EdgeOtherVertexTreeNode (com.alibaba.maxgraph.compiler.tree.EdgeOtherVertexTreeNode)1 EdgeTreeNode (com.alibaba.maxgraph.compiler.tree.EdgeTreeNode)1 EdgeVertexTreeNode (com.alibaba.maxgraph.compiler.tree.EdgeVertexTreeNode)1 TreeNode (com.alibaba.maxgraph.compiler.tree.TreeNode)1 VertexTreeNode (com.alibaba.maxgraph.compiler.tree.VertexTreeNode)1 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 CustomPredicate (com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate)1 ListKeyPredicate (com.alibaba.maxgraph.sdkcommon.compiler.custom.ListKeyPredicate)1