本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.IBooleanFilter.setOperation方法的典型用法代码示例。如果您正苦于以下问题:Java IBooleanFilter.setOperation方法的具体用法?Java IBooleanFilter.setOperation怎么用?Java IBooleanFilter.setOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.expression.IBooleanFilter
的用法示例。
在下文中一共展示了IBooleanFilter.setOperation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copy
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public IBooleanFilter copy() {
IBooleanFilter filterNew = ASTNodeFactory.getInstance().createBooleanFilter();
super.copy(filterNew);
filterNew.setOperation(this.getOperation());
if (this.getValues() != null) {
List<Object> vals = getValues();
List<Object> newVals = new ArrayList(vals.size());
for (Object val : vals) {
if (val instanceof IBindVal) {
newVals.add(((IBindVal) val).copy());
} else if (val instanceof ISelectable) {
newVals.add(((ISelectable) val).copy());
} else {
newVals.add(val);
}
}
filterNew.setValues(newVals);
}
return filterNew;
}
示例2: 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);
}
}
示例3: equal
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 创建equal filter
*/
public static IBooleanFilter equal(Object columnName, Object value) {
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.EQ);
f.setColumn(columnName);
f.setValue(value);
return f;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: copy
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public IBooleanFilter copy() {
IBooleanFilter filterNew = ASTNodeFactory.getInstance().createBooleanFilter();
super.copy(filterNew);
filterNew.setOperation(this.getOperation());
return filterNew;
}
示例9: mgetWithDuplicate
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
IQuery tmpQuery = (IQuery) query.copy();
List<Object> values = new ArrayList<Object>();
String cm = keys.get(0).getColumnList().get(0);
for (CloneableRecord key : keys) {
values.add(key.get(cm));
}
IColumn ic = ASTNodeFactory.getInstance().createColumn();
ic.setColumnName(cm);
IBooleanFilter targetFilter = ASTNodeFactory.getInstance().createBooleanFilter();
targetFilter.setOperation(OPERATION.IN);
targetFilter.setColumn(ic);
targetFilter.setValues(values);
tmpQuery.setKeyFilter(FilterUtils.and(tmpQuery.getKeyFilter(), targetFilter));
myJdbcHandler.setPlan(tmpQuery);
try {
myJdbcHandler.executeQuery(this.meta, isStreaming);
} catch (SQLException e) {
throw new TddlException(e);
}
Map<CloneableRecord, DuplicateKVPair> res = buildDuplicateKVPair(keys);
return res;
}
示例10: equal
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
* 创建equal filter
*/
public static IBooleanFilter equal(Comparable columnName, Comparable value) {
IBooleanFilter f = ASTNodeFactory.getInstance().createBooleanFilter();
f.setOperation(OPERATION.EQ);
f.setColumn(columnName);
f.setValue(value);
return f;
}
示例11: 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;
}
示例12: getRecordFromRightByValueFilter
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
protected Map<CloneableRecord, DuplicateKVPair> getRecordFromRightByValueFilter(List<CloneableRecord> leftJoinOnColumnCache)
throws TddlException {
right_cursor.beforeFirst();
if (isLeftOutJoin() && this.rightCursorMeta == null) {
IRowSet kv = right_cursor.next();
if (kv != null) {
this.rightCursorMeta = kv.getParentCursorMeta();
} else {
rightCursorMeta = CursorMetaImp.buildNew(right_cursor.getReturnColumns());
}
right_cursor.beforeFirst();
}
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
for (CloneableRecord record : leftJoinOnColumnCache) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 单字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
ibf.setColumn(this.rightJoinOnColumns.get(0).copy());
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
IColumn rightColumn = (IColumn) this.rightJoinOnColumns.get(0);
IValueFilterCursor vfc = this.cursorFactory.valueFilterCursor(executionContext, right_cursor, ibf);
Map<CloneableRecord, DuplicateKVPair> records = new HashMap();
if (isLeftOutJoin() && !isRightOutJoin()) {
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else if (!isLeftOutJoin() && !isRightOutJoin()) {
// inner join
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else {
throw new UnsupportedOperationException("leftOutJoin:" + isLeftOutJoin() + " ; rightOutJoin:"
+ isRightOutJoin());
}
return records;
}
示例13: mgetWithDuplicate
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
init();
if (prefixMatch) {
throw new UnsupportedOperationException("not supported yet");
} else {
// 这里列的别名也丢了吧 似乎解决了
IQuery iquery = (IQuery) merge.getSubNode();
OptimizerContext optimizerContext = OptimizerContext.getContext();
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
String colName = null;
for (CloneableRecord record : keys) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 单字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
colName = entry.getKey();
IColumn col = ASTNodeFactory.getInstance()
.createColumn()
.setColumnName(colName)
.setDataType(record.getType(0));
col.setTableName(iquery.getAlias());
ibf.setColumn(col);
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
KVIndexNode query = (KVIndexNode) OptimizerUtils.convertPlanToAst(iquery);
if (keyFilterOrValueFilter) {
query.keyQuery(FilterUtils.and(removeDupFilter(query.getKeyFilter(), ibf), ibf));
} else {
query.valueQuery(FilterUtils.and(removeDupFilter(query.getResultFilter(), ibf), ibf));
}
query.build();
// 优化做法,将数据分配掉。
Integer currentThread = merge.getThread();
executionContext.getExtraCmds().put("initThread", currentThread);
IDataNodeExecutor idne = optimizerContext.getOptimizer().optimizePlan(query,
executionContext.getParams(),
executionContext.getExtraCmds());
ISchematicCursor cursor = null;
Map<CloneableRecord, DuplicateKVPair> duplicateKeyMap = null;
try {
cursor = ExecutorContext.getContext().getTopologyExecutor().execByExecPlanNode(idne, executionContext);
// 用于关闭,统一管理
this.returnColumns = cursor.getReturnColumns();
List<IColumn> cols = new ArrayList<IColumn>();
if (ibf.getColumn() instanceof IColumn) {
cols.add((IColumn) ibf.getColumn());
} else {
cols.addAll(((IFunction) ibf.getColumn()).getArgs());
}
duplicateKeyMap = buildDuplicateKVPairMap(cols, cursor);
} finally {
if (cursor != null) {
List<TddlException> exs = new ArrayList();
exs = cursor.close(exs);
if (!exs.isEmpty()) {
throw GeneralUtil.mergeException(exs);
}
}
}
return duplicateKeyMap;
}
}
示例14: mgetWithDuplicate
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
IQuery tmpQuery = (IQuery) query.copy();
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
String colName = null;
for (CloneableRecord record : keys) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 单字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
colName = entry.getKey();
IColumn col = ASTNodeFactory.getInstance()
.createColumn()
.setColumnName(colName)
.setDataType(record.getType(0));
col.setTableName(tmpQuery.getAlias());
ibf.setColumn(col);
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
tmpQuery.setKeyFilter(FilterUtils.and(tmpQuery.getKeyFilter(), ibf));
myJdbcHandler.setPlan(tmpQuery);
try {
myJdbcHandler.executeQuery(this.meta, isStreaming);
} catch (SQLException e) {
throw new TddlException(e);
}
buildReturnColumns();
Map<CloneableRecord, DuplicateKVPair> res = buildDuplicateKVPair(keys);
return res;
}
示例15: visit
import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
@Override
public void visit(ComparisionIsExpression node) {
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
MySqlExprVisitor leftEvi = new MySqlExprVisitor(parent);
node.getOperand().accept(leftEvi);
ibf.setColumn(leftEvi.getColumnOrValue());
if (node.getMode() == ComparisionIsExpression.IS_NULL) {
ibf.setOperation(OPERATION.IS_NULL);
// ibf.setValue(NullValue.getNullValue());
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_NOT_NULL) {
ibf.setOperation(OPERATION.IS_NOT_NULL);
// ibf.setValue(NullValue.getNullValue());
// ibf.setIsNot(true);
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_FALSE) {
ibf.setOperation(OPERATION.IS_FALSE);
// ibf.setValue(false);
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_NOT_FALSE) {
ibf.setOperation(OPERATION.IS_NOT_FALSE);
// ibf.setValue(new Boolean(false));
// ibf.setIsNot(true);
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_TRUE) {
ibf.setOperation(OPERATION.IS_TRUE);
// ibf.setValue(new Boolean(true));
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_NOT_TRUE) {
ibf.setOperation(OPERATION.IS_NOT_TRUE);
// ibf.setValue(new Boolean(true));
// ibf.setIsNot(true);
ibf.setIsNot(false);
} else if (node.getMode() == ComparisionIsExpression.IS_UNKNOWN) {
throw new NotSupportException("not support IS_UNKNOWN");
} else if (node.getMode() == ComparisionIsExpression.IS_NOT_UNKNOWN) {
throw new NotSupportException("not support IS_NOT_UNKNOWN");
}
this.filter = ibf;
}