本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.ISelectable.copy方法的典型用法代码示例。如果您正苦于以下问题:Java ISelectable.copy方法的具体用法?Java ISelectable.copy怎么用?Java ISelectable.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.expression.ISelectable
的用法示例。
在下文中一共展示了ISelectable.copy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copySelectables
import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public static List<ISelectable> copySelectables(List<ISelectable> selects, String oldTableName, String tableName) {
if (tableName == null) {
return copySelectables(selects);
}
if (selects == null) {
return null;
}
List<ISelectable> news = new ArrayList(selects.size());
for (ISelectable s : selects) {
ISelectable a = s.copy();
if (a instanceof IColumn) {
setColumn((IColumn) a, oldTableName, tableName);
} else if (a instanceof IFilter) {
setFilter((IFilter) a, oldTableName, tableName);
} else if (a instanceof IFunction) {
setFunction((IFunction) a, oldTableName, tableName);
}
news.add(a);
}
return news;
}
示例2: getColumnsSelectedForParent
import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
* 列的tablename会设为表别名
*
* @return
*/
public List<ISelectable> getColumnsSelectedForParent() {
List<ISelectable> res = new ArrayList<ISelectable>(this.getColumnsSelected().size());
for (ISelectable s : this.getColumnsSelected()) {
ISelectable a = s.copy();
if (this.getAlias() != null) {
a.setTableName(this.getAlias());
}
if (s.getAlias() != null) {
a.setColumnName(s.getAlias()); // 设置为alias name
a.setAlias(null);
}
res.add(a);
}
return res;
}
示例3: getColumnsReferedForParent
import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
* 列的tablename会设为表别名
*
* @return
*/
public List<ISelectable> getColumnsReferedForParent() {
if (this.getAlias() == null) {
return this.getColumnsRefered();
} else {
List<ISelectable> res = new ArrayList<ISelectable>(this.getColumnsRefered().size());
for (ISelectable s : this.getColumnsRefered()) {
ISelectable a = s.copy();
if (this.getAlias() != null) {
a.setTableName(this.getAlias());
}
if (s.getAlias() != null) {
a.setColumnName(s.getAlias()); // 设置为alias name
a.setAlias(null);
}
res.add(a);
}
return res;
}
}
示例4: copySelectables
import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
public static List<ISelectable> copySelectables(List<ISelectable> selects, String tableName) {
if (tableName == null) {
return copySelectables(selects);
}
if (selects == null) {
return null;
}
List<ISelectable> news = new ArrayList(selects.size());
for (ISelectable s : selects) {
ISelectable a = s.copy();
if (a instanceof IColumn) {
setColumn((IColumn) a, tableName);
} else if (a instanceof IFilter) {
setFilter((IFilter) a, tableName);
} else if (a instanceof IFunction) {
setFunction((IFunction) a, tableName);
}
news.add(a);
}
return news;
}
示例5: expendAvgFunction
import com.taobao.tddl.optimizer.core.expression.ISelectable; //导入方法依赖的package包/类
/**
* 将Avg函数展开为sum/count
*/
private void expendAvgFunction(IDataNodeExecutor sub) {
if (sub instanceof IQuery || sub instanceof IJoin) {
List<ISelectable> add = new ArrayList();
List<ISelectable> remove = new ArrayList();
for (Object sel : ((IQueryTree) sub).getColumns()) {
ISelectable s = (ISelectable) sel;
if (s instanceof IFunction) {
if (s.getColumnName().startsWith("AVG(")) {
IFunction sum = (IFunction) s.copy();
sum.setExtraFunction(null);
sum.setFunctionName("SUM");
sum.setColumnName(s.getColumnName().replace("AVG(", "SUM("));
if (sum.getAlias() != null) {
sum.setAlias(sum.getAlias() + "1");// 加个后缀1
}
IFunction count = (IFunction) s.copy();
count.setExtraFunction(null);
count.setFunctionName("COUNT");
count.setColumnName(s.getColumnName().replace("AVG(", "COUNT("));
if (count.getAlias() != null) {
count.setAlias(count.getAlias() + "2");// 加个后缀2
}
add.add(count);
add.add(sum);
remove.add(s);
} else {
// 删除底下AVG的相关函数,比如 1 + AVG(ID)
// 目前这个只能上层来进行计算
// 可能的风险:还未支持的Function计算
if (FunctionType.Scalar.equals(((IFunction) s).getFunctionType())
&& hasArgsAvgFunction((IFunction) s)) {
remove.add(s);
}
}
}
}
if (!remove.isEmpty()) {
((IQueryTree) sub).getColumns().removeAll(remove);
((IQueryTree) sub).getColumns().addAll(add);
}
}
}