當前位置: 首頁>>代碼示例>>Java>>正文


Java FunctionType類代碼示例

本文整理匯總了Java中com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType的典型用法代碼示例。如果您正苦於以下問題:Java FunctionType類的具體用法?Java FunctionType怎麽用?Java FunctionType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FunctionType類屬於com.taobao.tddl.optimizer.core.expression.IFunction包,在下文中一共展示了FunctionType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildFunction

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
protected void buildFunction(IFunction f, boolean findInSelectList) {
    if (FunctionType.Aggregate == f.getFunctionType()) {
        setExistAggregate();
    }

    if (f.getArgs().size() == 0) {
        return;
    }

    List<Object> args = f.getArgs();
    for (int i = 0; i < args.size(); i++) {
        if (args.get(i) instanceof ISelectable) {
            args.set(i, this.buildSelectable((ISelectable) args.get(i), findInSelectList));
        } else if (args.get(i) instanceof ISequenceVal) {
            setExistSequenceVal();
        }
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:19,代碼來源:QueryTreeNodeBuilder.java

示例2: buildFunction

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
@Override
public void buildFunction(IFunction f, boolean findInSelectList) {
    if (FunctionType.Aggregate == f.getFunctionType()) {
        setExistAggregate();
    }

    for (Object arg : f.getArgs()) {
        if (arg instanceof IFunction) {
            this.buildSelectable((ISelectable) arg, findInSelectList);
        } else if (!this.getNode().isDistinctByShardColumns() && arg instanceof ISelectable) {
            // 針對非distinct的函數,沒必要下推字段
            if (((ISelectable) arg).isDistinct()) {
                this.buildSelectable((ISelectable) arg, findInSelectList);
            }
        }
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:18,代碼來源:MergeNodeBuilder.java

示例3: getAggregatesCommon

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
/**
 * 從select [columns] 裏麵獲取aggregate functions
 * 
 * @param retColumns
 * @return
 */
protected List<IFunction> getAggregatesCommon(List retColumns, boolean isMergeAggregates) {
    List<IFunction> aggregates = new ArrayList<IFunction>();
    for (int i = 0; i < retColumns.size(); i++) {
        Object o = retColumns.get(i);
        if (o instanceof IFunction) {
            // 如果retColumn中出現了函數名字,那麽進入這個邏輯
            IFunction f = (IFunction) o;
            if (FunctionType.Aggregate.equals(f.getFunctionType())) {
                aggregates.add(f);
            } else {
                List<IFunction> aggregateInThisScalar = new ArrayList();
                findAggregateFunctionsInScalar(f, aggregateInThisScalar);
                if (!aggregateInThisScalar.isEmpty()) {
                    aggregates.add(f);
                }
            }
        }
    }
    return aggregates;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:27,代碼來源:QueryHandlerCommon.java

示例4: buildFunction

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
public void buildFunction(IFunction f, boolean findInSelectList) {
    if (FunctionType.Aggregate == f.getFunctionType()) {
        setExistAggregate();
    }

    if (f.getArgs().size() == 0) {
        return;
    }

    List<Object> args = f.getArgs();
    for (int i = 0; i < args.size(); i++) {
        if (args.get(i) instanceof ISelectable) {
            args.set(i, this.buildSelectable((ISelectable) args.get(i), findInSelectList));
        }
    }
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:17,代碼來源:QueryTreeNodeBuilder.java

示例5: getArgValue

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
protected Object getArgValue(Object funcArg, IRowSet kvPair, ExecutionContext ec) {
    if (funcArg instanceof IFunction) {
        if (((IFunction) funcArg).getExtraFunction().getFunctionType().equals(FunctionType.Aggregate)) {
            // aggregate function
            return ExecUtils.getValueByIColumn(kvPair, ((ISelectable) funcArg));

        } else {
            // scalar function

            return ((ScalarFunction) ((IFunction) funcArg).getExtraFunction()).scalarCalucate(kvPair, ec);
        }
    } else if (funcArg instanceof ISelectable) {// 如果是IColumn,那麽應該從輸入的參數中獲取對應column
        if (IColumn.STAR.equals(((ISelectable) funcArg).getColumnName())) {
            return kvPair;
        } else {
            return ExecUtils.getValueByIColumn(kvPair, ((ISelectable) funcArg));
        }
    } else if (funcArg instanceof List) {
        List newArg = new ArrayList(((List) funcArg).size());

        for (Object subArg : (List) funcArg) {
            newArg.add(this.getArgValue(subArg, kvPair, ec));
        }

        return newArg;
    } else {
        return funcArg;
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:30,代碼來源:ExtraFunction.java

示例6: getFunctionsNeedToCalculate

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
/**
 * <pre>
 * 需要計算的函數
 * query節點中
 *  1、scalar函數
 *  2、aggregate函數
 * merge節點中
 *  1、聚合函數
 *  2、子節點中有aggregate函數的scalar函數
 * </pre>
 * 
 * @param columns
 * @return
 */
protected List<IFunction> getFunctionsNeedToCalculate(List columns, boolean isMergeAggregates) {
    List<IFunction> aggregates = new ArrayList<IFunction>();
    for (int i = 0; i < columns.size(); i++) {
        Object o = columns.get(i);
        if (o instanceof IFunction) {
            // 如果retColumn中出現了函數名字,那麽進入這個邏輯
            IFunction f = (IFunction) o;
            if (FunctionType.Aggregate.equals(f.getFunctionType())) {
                aggregates.add(f);
            } else {
                List<IFunction> aggregateInThisScalar = new ArrayList();
                findAggregateFunctionsInScalar(f, aggregateInThisScalar);

                // 包含聚合函數
                if (!aggregateInThisScalar.isEmpty()) {
                    aggregates.add(f);

                    aggregates.addAll(aggregateInThisScalar);
                } else {
                    // 不包含聚合函數,merge中就不需要再算一次了
                    if (!isMergeAggregates) {
                        aggregates.add(f);
                    }
                }
            }
        }
    }
    return aggregates;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:44,代碼來源:QueryHandlerCommon.java

示例7: findAggregateFunctionsInScalar

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
private void findAggregateFunctionsInScalar(IFunction s, List<IFunction> res) {
    if (IFunction.FunctionType.Aggregate.equals(s.getFunctionType())) {
        res.add(s);
    }

    for (Object arg : s.getArgs()) {
        if (arg instanceof IFunction) {
            this.findAggregateFunctionsInScalar((IFunction) arg, res);
        }
    }

}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:13,代碼來源:QueryHandlerCommon.java

示例8: putRetColumnInMeta

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
void putRetColumnInMeta(ISelectable column, List<ColumnMeta> metaColumns) {
    String columnName;

    columnName = column.getColumnName();
    DataType type = null;

    // 函數在Map和Reduce過程中的返回類型可以不同
    // 如Avg,map過程返回String
    // reduce過程中返回數字類型
    if (this.isMerge()) {
        type = column.getDataType();
    } else {
        if (column instanceof IFunction) {

            if (((IFunction) column).getFunctionType().equals(FunctionType.Aggregate)) {
                type = ((AggregateFunction) ((IFunction) column).getExtraFunction()).getMapReturnType();
            } else {
                type = column.getDataType();
            }
        } else {
            type = column.getDataType();
        }
    }

    ColumnMeta cm = new ColumnMeta(ExecUtils.getLogicTableName(column.getTableName()),
        columnName,
        type,
        column.getAlias(),
        true);
    metaColumns.add(cm);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:32,代碼來源:AggregateCursor.java

示例9: findAggregateFunctionsInScalar

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
private void findAggregateFunctionsInScalar(IFunction s, List<IFunction> res) {
    if (IFunction.FunctionType.Aggregate.equals(s.getFunctionType())) {
        res.add(s);
    }

    for (Object arg : s.getArgs()) {
        if (arg instanceof IFunction) {
            this.findAggregateFunctionsInScalar((IFunction) arg, res);
        }
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:12,代碼來源:MergeNodeBuilder.java

示例10: serverMap

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
/**
 * 外部執行器傳遞ResultSet中的row記錄,進行function的map計算
 * 
 * @param kvPair
 * @throws Exception
 */
public void serverMap(IRowSet kvPair) throws TddlRuntimeException {
    // 當前function需要的args 有些可能是函數,也有些是其他的一些數據
    List<Object> argsArr = getMapArgs(function);
    // 函數的input參數
    Object[] inputArg = new Object[argsArr.size()];
    int index = 0;
    for (Object funcArg : argsArr) {
        if (funcArg instanceof IFunction) {
            if (((IFunction) funcArg).getExtraFunction().getFunctionType().equals(FunctionType.Aggregate)) {
                // aggregate function
                inputArg[index] = ((AggregateFunction) ((IFunction) funcArg).getExtraFunction()).getResult();
                index++;
            } else {
                // scalar function
                ((ScalarFunction) ((IFunction) funcArg).getExtraFunction()).serverMap(kvPair);
                inputArg[index] = ((ScalarFunction) ((IFunction) funcArg).getExtraFunction()).getResult();
                index++;
            }
        } else if (funcArg instanceof ISelectable) {// 如果是IColumn,那麽應該從輸入的參數中獲取對應column
            if (IColumn.STAR.equals(((ISelectable) funcArg).getColumnName())) {
                inputArg[index] = kvPair;
            } else {
                inputArg[index] = ExecUtils.getValueByIColumn(kvPair, ((ISelectable) funcArg));
            }
            index++;
        } else {
            inputArg[index] = funcArg;
            index++;
        }
    }

    serverMap(inputArg);
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:40,代碼來源:ExtraFunction.java

示例11: AggregateCursor

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
public AggregateCursor(ISchematicCursor cursor, List<IFunction> functions, List<IOrderBy> groupBycols,
                       List<ISelectable> retColumns, boolean isMerge){
    super(cursor, null, cursor.getOrderBy());

    this.groupBys.addAll(ExecUtils.getColumnMetaWithLogicTablesFromOrderBys(groupBycols));
    for (IFunction f : functions) {
        if (f.getFunctionType().equals(FunctionType.Scalar)) {
            this.scalars.add(f);
        }
    }
    this.aggregates.addAll(this.getAllAggregates(functions));
    this.isMerge = isMerge;

}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:15,代碼來源:AggregateCursor.java

示例12: getAllAggregates

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
public List<IFunction> getAllAggregates(List<IFunction> functions) {
    List<IFunction> aggregates = new LinkedList<IFunction>();

    for (IFunction f : functions) {
        List<IFunction> functionsInArgs = new ArrayList<IFunction>(f.getArgs().size());

        for (Object arg : f.getArgs()) {
            if (arg instanceof IFunction) {
                functionsInArgs.add((IFunction) arg);
            }
        }
        List<IFunction> aggregatesInArgs = this.getAllAggregates(functionsInArgs);
        aggregates.addAll(aggregatesInArgs);

        if (f.getFunctionType().equals(FunctionType.Aggregate)) {
            aggregates.add(f);

            // 聚合函數不能使用聚合函數作為參數
            // 如 max(count(id))是錯誤的
            if (!aggregatesInArgs.isEmpty()) {
                throw new RuntimeException("Invalid use of group function");
            }
        }
    }

    return aggregates;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:28,代碼來源:AggregateCursor.java

示例13: processFunction

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
private Object processFunction(IRowSet iRowSet, Object c) throws TddlException {
    Object v = null;
    // 在Filter裏麵是不能出現聚合函數的
    if (((IFunction) c).getFunctionType().equals(FunctionType.Aggregate)) throw new RuntimeException("Invalid use of group function");
    ((ExtraFunction) ((IFunction) c).getExtraFunction()).serverMap(iRowSet);

    v = ((IFunction) c).getExtraFunction().getResult();
    return v;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:10,代碼來源:ValueFilterCursor.java

示例14: getFunctionType

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
@Override
public FunctionType getFunctionType() {
    return FunctionType.Scalar;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:5,代碼來源:ScalarFunction.java

示例15: getFunctionType

import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
@Override
public FunctionType getFunctionType() {
    return FunctionType.Aggregate;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:5,代碼來源:AggregateFunction.java


注:本文中的com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。