本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.IBooleanFilter.setColumnName方法的典型用法代码示例。如果您正苦于以下问题:Java IBooleanFilter.setColumnName方法的具体用法?Java IBooleanFilter.setColumnName怎么用?Java IBooleanFilter.setColumnName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.expression.IBooleanFilter
的用法示例。
在下文中一共展示了IBooleanFilter.setColumnName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: merge
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 将filter中的and/or条件中进行Range合并处理 <br/>
*
* <pre>
* 比如:
* a. A =1 And A =2 ,永远false条件,返回EmptyResultFilterException异常
* b. (1 < A < 5) or (2 < A < 6),合并为 (1 < A < 6)
* c. A <= 1 or A = 1,永远true条件
* </pre>
*/
public static IFilter merge(IFilter filter) throws EmptyResultFilterException {
if (filter == null || filter instanceof IBooleanFilter) {
return filter;
}
// 先转为DNF结构
filter = toDNFAndFlat(filter);
List<List<IFilter>> DNFNodes = toDNFNodesArray(filter);
if (!needToMerge(DNFNodes)) {
return filter;
}
DNFNodes = mergeOrDNFNodes(mergeAndDNFNodesArray(DNFNodes));
if (DNFNodes == null || DNFNodes.isEmpty() || DNFNodes.get(0) == null || DNFNodes.get(0).isEmpty()
|| DNFNodes.get(0).get(0) == null) {
// 返回常量true
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn("1");
f.setColumnName(ObjectUtils.toString("1"));
return f;
} else {
return DNFToOrLogicTree(DNFNodes);
}
}
示例2: buildBooleanFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
public IBooleanFilter buildBooleanFilter(Object column, Object value, OPERATION operation, Expression exp) {
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setColumn(column);
ibf.setValue(value);
ibf.setOperation(operation);
if (exp != null) {
ibf.setColumnName(getSqlExprStr(exp)); // 比如将count(*)做为columnName
}
return ibf;
}
示例3: buildConstanctFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
public IBooleanFilter buildConstanctFilter(Object constant) {
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn(constant);
f.setColumnName(ObjectUtils.toString(constant));
return f;
}
示例4: buildConstanctFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
private static IBooleanFilter buildConstanctFilter(Object constant, String alias) {
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn(constant);
f.setColumnName(ObjectUtils.toString(constant));
f.setAlias(alias);
return f;
}
示例5: buildConstanctFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
public IBooleanFilter buildConstanctFilter(Comparable constant) {
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn(constant);
f.setColumnName(ObjectUtils.toString(constant));
return f;
}
示例6: shortestFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 将0=1/1=1/true的恒等式进行优化
*/
private static IFilter shortestFilter(IFilter root) throws EmptyResultFilterException {
IFilter filter = FilterUtils.toDNFAndFlat(root);
List<List<IFilter>> DNFfilter = FilterUtils.toDNFNodesArray(filter);
List<List<IFilter>> newDNFfilter = new ArrayList<List<IFilter>>();
for (List<IFilter> andDNFfilter : DNFfilter) {
boolean isShortest = false;
List<IFilter> newAndDNFfilter = new ArrayList<IFilter>();
for (IFilter one : andDNFfilter) {
if (one.getOperation() == OPERATION.CONSTANT) {
boolean flag = false;
if (((IBooleanFilter) one).getColumn() instanceof ISelectable) {// 可能是个not函数
newAndDNFfilter.add(one);// 不能丢弃
} else {
Object value = ((IBooleanFilter) one).getColumn();
if (value == null) {
flag = false;
} else if (value.getClass() == Boolean.class || value.getClass() == boolean.class) {
flag = (Boolean) value;
} else {
// mysql中字符串'true'会被当作0处理
flag = (DataType.LongType.convertFrom(value) != 0);
}
// if (StringUtils.isNumeric(value)) {
// flag =
// BooleanUtils.toBoolean(Integer.valueOf(value));
// } else {
// flag = BooleanUtils.toBoolean(((IBooleanFilter)
// one).getColumn().toString());
// }
if (!flag) {
isShortest = true;
break;
}
}
} else {
newAndDNFfilter.add(one);
}
}
if (!isShortest) {
if (newAndDNFfilter.isEmpty()) {
// 代表出现为true or xxx,直接返回true
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn("1");
f.setColumnName(ObjectUtils.toString("1"));
return f;
} else {// 针对非false的情况
newDNFfilter.add(newAndDNFfilter);
}
}
}
if (newDNFfilter.isEmpty()) {
throw new EmptyResultFilterException();
}
return FilterUtils.DNFToOrLogicTree(newDNFfilter);
}
示例7: shortestFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 将0=1/1=1/true的恒等式进行优化
*/
private static IFilter shortestFilter(IFilter root) throws EmptyResultFilterException {
IFilter filter = FilterUtils.toDNFAndFlat(root);
List<List<IFilter>> DNFfilter = FilterUtils.toDNFNodesArray(filter);
List<List<IFilter>> newDNFfilter = new ArrayList<List<IFilter>>();
for (List<IFilter> andDNFfilter : DNFfilter) {
boolean isShortest = false;
List<IFilter> newAndDNFfilter = new ArrayList<IFilter>();
for (IFilter one : andDNFfilter) {
if (one.getOperation() == OPERATION.CONSTANT) {
boolean flag = false;
if (((IBooleanFilter) one).getColumn() instanceof ISelectable) {// 可能是个not函数
newAndDNFfilter.add(one);// 不能丢弃
} else {
String value = ((IBooleanFilter) one).getColumn().toString();
if (StringUtils.isNumeric(value)) {
flag = BooleanUtils.toBoolean(Integer.valueOf(value));
} else {
flag = BooleanUtils.toBoolean(((IBooleanFilter) one).getColumn().toString());
}
if (!flag) {
isShortest = true;
break;
}
}
} else {
newAndDNFfilter.add(one);
}
}
if (!isShortest) {
if (newAndDNFfilter.isEmpty()) {
// 代表出现为true or xxx,直接返回true
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.CONSTANT);
f.setColumn("1");
f.setColumnName(ObjectUtils.toString("1"));
return f;
} else {// 针对非false的情况
newDNFfilter.add(newAndDNFfilter);
}
}
}
if (newDNFfilter.isEmpty()) {
throw new EmptyResultFilterException("空结果");
}
return FilterUtils.DNFToOrLogicTree(newDNFfilter);
}