本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.IBooleanFilter.getOperation方法的典型用法代码示例。如果您正苦于以下问题:Java IBooleanFilter.getOperation方法的具体用法?Java IBooleanFilter.getOperation怎么用?Java IBooleanFilter.getOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.expression.IBooleanFilter
的用法示例。
在下文中一共展示了IBooleanFilter.getOperation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: manageToBooleanRangeCursor
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
protected ISchematicCursor manageToBooleanRangeCursor(ExecutionContext executionContext, ISchematicCursor cursor,
IRepository repo, IFilter keyFilter) throws TddlException {
IBooleanFilter bf = (IBooleanFilter) keyFilter;
IColumn c = ExecUtils.getColumn(bf.getColumn());
OPERATION op = bf.getOperation();
if (op == OPERATION.IN) {
List<Object> values = bf.getValues();
if (values == null) {
throw new IllegalArgumentException("values is null ,but operation is in . logical error");
} else {
return repo.getCursorFactory().inCursor(executionContext, cursor, cursor.getOrderBy(), c, values, op);
}
}
try {
cursor = repo.getCursorFactory().rangeCursor(executionContext, cursor, keyFilter);
} catch (Exception e) {
throw new RuntimeException(e);
}
return cursor;
}
示例2: findBooleanFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
private static void findBooleanFilter(IBooleanFilter filter, Parameters parameters) {
if (filter == null) {
return;
}
findObject(filter.getColumn(), parameters);
findObject(filter.getValue(), parameters);
if (filter.getOperation() == OPERATION.IN) {
List<Object> values = filter.getValues();
if (values != null && !values.isEmpty()) {
for (int i = 0; i < values.size(); i++) {
findObject(values.get(i), parameters);
}
}
}
}
示例3: manageToBooleanRangeCursor
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
protected ISchematicCursor manageToBooleanRangeCursor(ISchematicCursor cursor, IRepository repo, IFilter keyFilter,
ExecutionContext executionContext) throws TddlException {
IBooleanFilter bf = (IBooleanFilter) keyFilter;
IColumn c = ExecUtils.getColumn(bf.getColumn());
OPERATION op = bf.getOperation();
if (op == OPERATION.IN) {
List<Object> values = bf.getValues();
if (values == null) {
throw new IllegalArgumentException("values is null ,but operation is in . logical error");
} else {
return repo.getCursorFactory().inCursor(executionContext, cursor, cursor.getOrderBy(), c, values, op);
}
}
try {
cursor = repo.getCursorFactory().rangeCursor(executionContext, cursor, keyFilter);
} catch (Exception e) {
throw new RuntimeException(e);
}
return cursor;
}
示例4: getRange
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 构造Range对象
*
* @param f
* @return
*/
protected Range getRange(IBooleanFilter f) {
DataType type = getColumn(f).getDataType();
if (type == null) {
type = DataTypeUtil.getTypeOfObject(f.getValue());
}
switch (f.getOperation()) {
case EQ:
return new Range(null, type, getValue(f), getValue(f));
case GT:
return new Range(null, type, getValue(f), false, null, true);
case GT_EQ:
return new Range(null, type, getValue(f), true, null, true);
case LT:
return new Range(null, type, null, true, getValue(f), false);
case LT_EQ:
return new Range(null, type, null, true, getValue(f), true);
default:
return null;
}
}
示例5: exchage
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 如果是1 = id的情况,转化为id = 1
*/
private static IFilter exchage(IFilter root) {
IBooleanFilter bf = (IBooleanFilter) root;
if (!FilterUtils.isConstValue(bf.getValue()) && FilterUtils.isConstValue(bf.getColumn())) {
Object val = bf.getColumn();
bf.setColumn(bf.getValue());
bf.setValue(val);
OPERATION newOp = bf.getOperation();
switch (bf.getOperation()) {
case GT:
newOp = OPERATION.LT;
break;
case LT:
newOp = OPERATION.GT;
break;
case GT_EQ:
newOp = OPERATION.LT_EQ;
break;
case LT_EQ:
newOp = OPERATION.GT_EQ;
break;
default:
break;
}
bf.setOperation(newOp);
}
return bf;
}
示例6: expandIn
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
private static IFilter expandIn(IFilter root, Map<String, Object> extraCmd) {
IBooleanFilter bf = (IBooleanFilter) root;
if (bf.getOperation() == OPERATION.IN && isExpandIn(extraCmd)) {
List<Object> values = bf.getValues();
IFilter newRoot = null;
for (Object value : values) {
newRoot = FilterUtils.or(newRoot, FilterUtils.equal(bf.getColumn(), value));
}
return newRoot;
} else {
return root;
}
}
示例7: equals
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof IBooleanFilter)) {
return false;
}
IBooleanFilter other = (IBooleanFilter) obj;
if (getOperation() != other.getOperation()) {
return false;
}
if (getColumn() == null) {
if (other.getColumn() != null) {
return false;
}
} else if (!getColumn().equals(other.getColumn())) {
return false;
}
if (getValue() == null) {
if (other.getValue() != null) {
return false;
}
} else if (!getValue().equals(other.getValue())) {
return false;
}
if (getValues() == null) {
if (other.getValues() != null) {
return false;
}
} else if (!getValues().equals(other.getValues())) {
return false;
}
return true;
}
示例8: buildBooleanFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
protected void buildBooleanFilter(IBooleanFilter filter, boolean findInSelectList) {
if (filter == null) {
return;
}
if (filter.getColumn() instanceof ISelectable) {
filter.setColumn(this.buildSelectable((ISelectable) filter.getColumn(), findInSelectList));
}
if (filter.getColumn() instanceof QueryTreeNode) {
// subQuery,比如WHERE ID = (SELECT ID FROM A)
((QueryTreeNode) filter.getColumn()).build();
}
if (filter.getValue() instanceof ISelectable) {
filter.setValue(this.buildSelectable((ISelectable) filter.getValue(), findInSelectList));
}
if (filter.getValue() instanceof QueryTreeNode) {
// subQuery,比如WHERE ID = (SELECT ID FROM A)
((QueryTreeNode) filter.getValue()).build();
}
if (filter.getOperation() == OPERATION.IN) {
List<Object> values = filter.getValues();
if (values != null && !values.isEmpty() && values.get(0) instanceof QueryTreeNode) {
// in的子查询
((QueryTreeNode) values.get(0)).build();
}
}
}
示例9: getRange
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 构造Range对象
*
* @param f
* @return
*/
protected Range getRange(IFilter filter) {
if (!(filter instanceof IBooleanFilter)) {
return null;
}
IBooleanFilter f = (IBooleanFilter) filter;
if (FilterUtils.isConstFilter(f)) {
return null;
}
if (filter.getOperation() == OPERATION.IN) {
// 不处理null
return null;
}
DataType type = getColumn(f).getDataType();
if (type == null) {
type = DataTypeUtil.getTypeOfObject(f.getValue());
}
if (!isNumberType(type)) {
// 只处理数字类型,避免时间戳类型的合并
return null;
}
switch (f.getOperation()) {
case EQ:
return new Range(null, type, getValue(f), getValue(f));
case GT:
return new Range(null, type, getValue(f), false, null, true);
case GT_EQ:
return new Range(null, type, getValue(f), true, null, true);
case LT:
return new Range(null, type, null, true, getValue(f), false);
case LT_EQ:
return new Range(null, type, null, true, getValue(f), true);
default:
return null;
}
}