Search in sources :

Example 6 with ValueValueType

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

the class AggregationListTreeNode method getOutputValueType.

@Override
public ValueType getOutputValueType() {
    Set<ValueType> aggValueList = Sets.newHashSet();
    aggNodeList.forEach(v -> aggValueList.add(v.getOutputValueType()));
    return new MapValueType(new ValueValueType(Message.VariantType.VT_STRING), aggValueList.size() > 1 ? new VarietyValueType(aggValueList) : aggValueList.iterator().next());
}
Also used : VarietyValueType(com.alibaba.maxgraph.compiler.tree.value.VarietyValueType) ValueType(com.alibaba.maxgraph.compiler.tree.value.ValueType) VarietyValueType(com.alibaba.maxgraph.compiler.tree.value.VarietyValueType) MapValueType(com.alibaba.maxgraph.compiler.tree.value.MapValueType) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) MapValueType(com.alibaba.maxgraph.compiler.tree.value.MapValueType) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType)

Example 7 with ValueValueType

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

the class TreeManager method validOrderResult.

/**
 * Add order node to reorder result
 */
private void validOrderResult() {
    TreeNode currentTreeNode = treeLeaf;
    TreeNode orderTreeNode = null;
    while (!(currentTreeNode instanceof SourceTreeNode)) {
        if (currentTreeNode instanceof OrderGlobalTreeNode) {
            orderTreeNode = currentTreeNode;
            break;
        } else {
            currentTreeNode = UnaryTreeNode.class.cast(currentTreeNode).getInputNode();
        }
    }
    if (null != orderTreeNode) {
        OrderGlobalTreeNode orderGlobalTreeNode = OrderGlobalTreeNode.class.cast(orderTreeNode);
        TreeNode aggTreeNode = orderTreeNode.getOutputNode();
        while (aggTreeNode != null && aggTreeNode.getNodeType() != NodeType.AGGREGATE) {
            aggTreeNode = aggTreeNode.getOutputNode();
        }
        if (null != aggTreeNode) {
            if (aggTreeNode instanceof FoldTreeNode) {
                TreeNode inputTreeNode = UnaryTreeNode.class.cast(aggTreeNode).getInputNode();
                if (inputTreeNode == orderTreeNode) {
                    return;
                }
                UnaryTreeNode inputUnaryTreeNode = UnaryTreeNode.class.cast(inputTreeNode);
                if (inputUnaryTreeNode.getInputNode() == orderTreeNode && (inputUnaryTreeNode instanceof EdgeVertexTreeNode && EdgeVertexTreeNode.class.cast(inputUnaryTreeNode).getDirection() != Direction.BOTH)) {
                    return;
                }
                String orderLabel = orderGlobalTreeNode.enableOrderFlag(labelManager);
                SelectOneTreeNode selectOneTreeNode = new SelectOneTreeNode(new SourceDelegateNode(inputUnaryTreeNode, schema), orderLabel, Pop.last, Lists.newArrayList(), schema);
                selectOneTreeNode.setConstantValueType(new ValueValueType(Message.VariantType.VT_INT));
                OrderGlobalTreeNode addOrderTreeNode = new OrderGlobalTreeNode(inputUnaryTreeNode, schema, Lists.newArrayList(Pair.of(selectOneTreeNode, Order.asc)));
                UnaryTreeNode.class.cast(aggTreeNode).setInputNode(addOrderTreeNode);
            }
        } else {
            if (treeLeaf instanceof OrderGlobalTreeNode) {
                return;
            }
            TreeNode currTreeNode = orderTreeNode.getOutputNode();
            boolean hasSimpleShuffle = false;
            while (currTreeNode != null) {
                if (currTreeNode.getNodeType() == NodeType.FLATMAP || (currTreeNode instanceof PropertyNode && !(UnaryTreeNode.class.cast(currTreeNode).getInputNode().getOutputValueType() instanceof EdgeValueType))) {
                    hasSimpleShuffle = true;
                    break;
                }
                currTreeNode = currTreeNode.getOutputNode();
            }
            if (!hasSimpleShuffle) {
                return;
            }
            UnaryTreeNode outputTreeNode = UnaryTreeNode.class.cast(treeLeaf);
            if (outputTreeNode.getInputNode() == orderTreeNode) {
                if (outputTreeNode instanceof EdgeVertexTreeNode && EdgeVertexTreeNode.class.cast(outputTreeNode).getDirection() != Direction.BOTH) {
                    return;
                }
                if (orderTreeNode.getOutputValueType() instanceof EdgeValueType && outputTreeNode instanceof PropertyNode) {
                    return;
                }
            }
            String orderLabel = orderGlobalTreeNode.enableOrderFlag(labelManager);
            SelectOneTreeNode selectOneTreeNode = new SelectOneTreeNode(new SourceDelegateNode(treeLeaf, schema), orderLabel, Pop.last, Lists.newArrayList(), schema);
            selectOneTreeNode.setConstantValueType(new ValueValueType(Message.VariantType.VT_INT));
            treeLeaf = new OrderGlobalTreeNode(treeLeaf, schema, Lists.newArrayList(Pair.of(selectOneTreeNode, Order.asc)));
        }
    }
}
Also used : SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) EdgeValueType(com.alibaba.maxgraph.compiler.tree.value.EdgeValueType) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) PropertyNode(com.alibaba.maxgraph.compiler.tree.addition.PropertyNode) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType)

Aggregations

ValueValueType (com.alibaba.maxgraph.compiler.tree.value.ValueValueType)7 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)3 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)3 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)3 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)3 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)3 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)3 ListValueType (com.alibaba.maxgraph.compiler.tree.value.ListValueType)2 Message (com.alibaba.maxgraph.Message)1 DataType (com.alibaba.maxgraph.compiler.api.schema.DataType)1 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)1 PropertyNode (com.alibaba.maxgraph.compiler.tree.addition.PropertyNode)1 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1 EdgeValueType (com.alibaba.maxgraph.compiler.tree.value.EdgeValueType)1 MapValueType (com.alibaba.maxgraph.compiler.tree.value.MapValueType)1 ValueType (com.alibaba.maxgraph.compiler.tree.value.ValueType)1 VarietyValueType (com.alibaba.maxgraph.compiler.tree.value.VarietyValueType)1 CustomPredicate (com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate)1