本文整理匯總了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();
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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));
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例14: getFunctionType
import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
@Override
public FunctionType getFunctionType() {
return FunctionType.Scalar;
}
示例15: getFunctionType
import com.taobao.tddl.optimizer.core.expression.IFunction.FunctionType; //導入依賴的package包/類
@Override
public FunctionType getFunctionType() {
return FunctionType.Aggregate;
}