Search in sources :

Example 1 with VariableParameterFunction

use of io.ordinate.engine.function.bind.VariableParameterFunction in project Mycat2 by MyCATApache.

the class CalciteCompiler method convertCorrelate.

public CorrelateJoinPlan convertCorrelate(Correlate correlate) {
    PhysicalPlan left = convert(correlate.getLeft());
    PhysicalPlan right = convert(correlate.getRight());
    CorrelationId correlationId = correlate.getCorrelationId();
    List<Integer> requireList = correlate.getRequiredColumns().asList();
    Map<CorrelationKey, List<VariableParameterFunction>> map = rexConverter.getVariableParameterFunctionMap();
    List<Map.Entry<CorrelationKey, List<VariableParameterFunction>>> entryList = map.entrySet().stream().filter(i -> i.getKey().correlationId.getId() == correlationId.getId()).collect(Collectors.toList());
    HashMap<Integer, List<VariableParameterFunction>> targetMap = new HashMap<>();
    for (Map.Entry<CorrelationKey, List<VariableParameterFunction>> e : entryList) {
        int index = e.getKey().index;
        Integer integer = requireList.get(index);
        for (VariableParameterFunction variableParameterFunction : e.getValue()) {
            targetMap.compute(integer, (integer1, variableParameterFunctions) -> new ArrayList<>()).add(variableParameterFunction);
        }
    }
    return new CorrelateJoinPlan(left, right, JoinType.valueOf(correlate.getJoinType().name()), targetMap);
}
Also used : MycatRelDataTypeUtil(io.mycat.calcite.MycatRelDataTypeUtil) Schema(org.apache.arrow.vector.types.pojo.Schema) java.util(java.util) AnyAccumulator(io.ordinate.engine.function.aggregate.any.AnyAccumulator) ColumnFunction(io.ordinate.engine.function.column.ColumnFunction) Getter(lombok.Getter) ImmutableList(com.google.common.collect.ImmutableList) RexNode(org.apache.calcite.rex.RexNode) IntFunction(io.ordinate.engine.function.IntFunction) MycatRelDataType(io.mycat.beans.mycat.MycatRelDataType) VariableParameterFunction(io.ordinate.engine.function.bind.VariableParameterFunction) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) RelDataType(org.apache.calcite.rel.type.RelDataType) org.apache.calcite.rel.core(org.apache.calcite.rel.core) InnerType(io.ordinate.engine.schema.InnerType) SqlKind(org.apache.calcite.sql.SqlKind) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) VectorExpression(io.ordinate.engine.vector.VectorExpression) MycatView(io.mycat.calcite.logical.MycatView) RexLiteral(org.apache.calcite.rex.RexLiteral) Function(io.ordinate.engine.function.Function) Field(org.apache.arrow.vector.types.pojo.Field) FactoryUtil(io.ordinate.engine.factory.FactoryUtil) RelNode(org.apache.calcite.rel.RelNode) MycatTableScan(io.mycat.calcite.table.MycatTableScan) RelFieldCollation(org.apache.calcite.rel.RelFieldCollation) Collectors(java.util.stream.Collectors) JoinType(org.apache.calcite.linq4j.JoinType) RelCollation(org.apache.calcite.rel.RelCollation) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) AccumulatorFunction(io.ordinate.engine.function.aggregate.AccumulatorFunction) IntConstant(io.ordinate.engine.function.constant.IntConstant) io.ordinate.engine.physicalplan(io.ordinate.engine.physicalplan) RexCall(org.apache.calcite.rex.RexCall) VariableParameterFunction(io.ordinate.engine.function.bind.VariableParameterFunction) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 MycatRelDataType (io.mycat.beans.mycat.MycatRelDataType)1 MycatRelDataTypeUtil (io.mycat.calcite.MycatRelDataTypeUtil)1 MycatView (io.mycat.calcite.logical.MycatView)1 MycatTableScan (io.mycat.calcite.table.MycatTableScan)1 FactoryUtil (io.ordinate.engine.factory.FactoryUtil)1 Function (io.ordinate.engine.function.Function)1 IntFunction (io.ordinate.engine.function.IntFunction)1 AccumulatorFunction (io.ordinate.engine.function.aggregate.AccumulatorFunction)1 AnyAccumulator (io.ordinate.engine.function.aggregate.any.AnyAccumulator)1 VariableParameterFunction (io.ordinate.engine.function.bind.VariableParameterFunction)1 ColumnFunction (io.ordinate.engine.function.column.ColumnFunction)1 IntConstant (io.ordinate.engine.function.constant.IntConstant)1 io.ordinate.engine.physicalplan (io.ordinate.engine.physicalplan)1 InnerType (io.ordinate.engine.schema.InnerType)1 VectorExpression (io.ordinate.engine.vector.VectorExpression)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Getter (lombok.Getter)1 Field (org.apache.arrow.vector.types.pojo.Field)1