当前位置: 首页>>代码示例>>Java>>正文


Java IBooleanFilter类代码示例

本文整理汇总了Java中com.taobao.tddl.optimizer.core.expression.IBooleanFilter的典型用法代码示例。如果您正苦于以下问题:Java IBooleanFilter类的具体用法?Java IBooleanFilter怎么用?Java IBooleanFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

IBooleanFilter类属于com.taobao.tddl.optimizer.core.expression包,在下文中一共展示了IBooleanFilter类的37个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:QueryHandler.java


示例2: convertFilterToLowerAndTopLimit

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
protected void convertFilterToLowerAndTopLimit(RangeMaker.Range range, IFilter lf, ICursorMeta cursorMetaNew) {
    if (lf instanceof IBooleanFilter) {
        processBoolfilter(range, lf, cursorMetaNew);
    } else if (lf instanceof ILogicalFilter) {
        ILogicalFilter lo = (ILogicalFilter) lf;
        if (lo.getOperation() == OPERATION.OR) {
            throw new IllegalStateException("or ? should not be here");
        }
        List<IFilter> list = lo.getSubFilter();
        for (IFilter filter : list) {
            convertFilterToLowerAndTopLimit(range, filter, cursorMetaNew);
        }
    } else if (lf instanceof IGroupFilter) {
        throw new IllegalStateException("or ? should not be here");
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:17,代码来源:RangeMaker.java


示例3: getColumnName

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private static String getColumnName(IBooleanFilter bf, int inden, boolean needTable) {
    if (bf == null) {
        return null;
    }

    if (needTable) {
        return bf.getColumn().toString();
    } else {
        List args = bf.getArgs();
        if (!args.isEmpty()) {
            Object obj = args.get(0);
            if (obj instanceof ISelectable) {
                return ((ISelectable) obj).getColumnName();
            } else if (obj instanceof Comparable) {
                return obj.toString();
            }
        }

        return null;
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:OptimizerToString.java


示例4: toColumnFiltersMap

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 根据column进行filter归类
 */
public static Map<Object, List<IFilter>> toColumnFiltersMap(List<IFilter> DNFNode) {
    Map<Object, List<IFilter>> columns = new HashMap(DNFNode.size());
    for (IFilter boolNode : DNFNode) {
        Object column = null;
        if (boolNode instanceof IBooleanFilter) {
            column = ((IBooleanFilter) boolNode).getColumn();
        } else if (boolNode instanceof IGroupFilter) {
            column = ((IGroupFilter) boolNode).getColumn();
        }
        if (!columns.containsKey(column)) {
            columns.put(column, new LinkedList());
        }

        columns.get(column).add(boolNode);
    }
    return columns;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:FilterUtils.java


示例5: addResultFilter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
public void addResultFilter(IBooleanFilter filter) {
    if (this.resultFilter == null) {
        this.resultFilter = filter;
        return;
    }

    if (this.resultFilter instanceof ILogicalFilter) {
        // 添加为子节点
        ((ILogicalFilter) resultFilter).addSubFilter(filter);
        setNeedBuild(true);
    } else {
        // 将自己做为一个Logical filter的子条件
        IFilter sub = this.resultFilter;
        resultFilter = ASTNodeFactory.getInstance().createLogicalFilter();
        resultFilter.setOperation(OPERATION.AND);
        ((ILogicalFilter) resultFilter).addSubFilter(sub);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:19,代码来源:QueryTreeNode.java


示例6: visit

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
@Override
public void visit(BetweenAndExpression node) {
    Expression first = node.getFirst();
    Expression second = node.getSecond();
    Expression third = node.getThird();

    MySqlExprVisitor v = new MySqlExprVisitor(parent);
    first.accept(v);
    Object col = v.getColumnOrValue();

    MySqlExprVisitor lv = new MySqlExprVisitor(parent);
    second.accept(lv);
    Object lval = lv.getColumnOrValue();

    MySqlExprVisitor rv = new MySqlExprVisitor(parent);
    third.accept(rv);
    Object rval = rv.getColumnOrValue();

    IBooleanFilter left = this.buildBooleanFilter(col, lval, OPERATION.GT_EQ, node);
    IBooleanFilter right = this.buildBooleanFilter(col, rval, OPERATION.LT_EQ, node);
    ILogicalFilter ilf = buildLogicalFilter(left, right, OPERATION.AND, node);
    if (node.isNot()) {
        ilf.setIsNot(true);
    }
    this.filter = ilf;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:MySqlExprVisitor.java


示例7: addJoinFilter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private void addJoinFilter(IBooleanFilter filter) {
    ISelectable left = (ISelectable) filter.getColumn();
    ISelectable right = (ISelectable) filter.getValue();
    if (!this.joinColumnsAndFilter.containsKey(left)) {
        this.joinColumnsAndFilter.put(left, new HashMap());
    }

    this.joinColumnsAndFilter.get(left).put(right, filter);
    // add by shenxun : 这里应该进行对调,map中应该维持左->右这个关系
    IBooleanFilter ibfnew = convertJoinOnColumns(filter);
    if (!this.joinColumnsAndFilter.containsKey(right)) {
        this.joinColumnsAndFilter.put(right, new HashMap());
    }

    this.joinColumnsAndFilter.get(right).put(left, ibfnew);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:17,代码来源:JoinPermutationGenerator.java


示例8: canJoinAndThenReturnFilters

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 找到left/right节点存在的join条件
 */
private List<IBooleanFilter> canJoinAndThenReturnFilters(QueryTreeNode leftNode, QueryTreeNode rightNode) {
    List<IBooleanFilter> filters = new LinkedList();
    for (ISelectable leftColumn : leftNode.getColumnsSelectedForParent()) {
        if (!this.joinColumnsAndFilter.containsKey(leftColumn)) {
            continue;
        }

        Map<ISelectable, IBooleanFilter> rightColumnsAndFilter = this.joinColumnsAndFilter.get(leftColumn);
        List<ISelectable> rightColumns = rightNode.getColumnsSelectedForParent();
        for (ISelectable rightColumn : rightColumnsAndFilter.keySet()) {
            if (rightColumns.contains(rightColumn)) {
                filters.add(rightColumnsAndFilter.get(rightColumn));
            }
        }
    }

    return filters;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:JoinPermutationGenerator.java


示例9: 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);
            }
        }
    }

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SequencePreProcessor.java


示例10: buildBooleanFilter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
protected void buildBooleanFilter(IBooleanFilter filter) {
    if (filter == null) {
        return;
    }

    Object column = filter.getColumn();
    Object value = filter.getValue();

    if (column instanceof ISelectable) {
        filter.setColumn(this.buildSelectable((ISelectable) column));
    }

    if (value instanceof ISelectable) {
        filter.setValue(this.buildSelectable((ISelectable) value));
    }

    if (value != null && value instanceof IFunction && ((IFunction) value).getArgs().size() > 0) {
        Object arg = ((IFunction) value).getArgs().get(0);
        if (arg instanceof QueryTreeNode) {
        }
    }

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:24,代码来源:BaseShowNode.java


示例11: 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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:BooleanFilter.java


示例12: testFunction_noArgs

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
@Test
public void testFunction_noArgs() throws Exception {
    String sql = "SELECT * FROM TABLE1 T1 WHERE ID = NOW()";
    QueryTreeNode qn = query(sql);
    qn.build();
    TableNode table1 = new TableNode("TABLE1");

    IFunction f = ASTNodeFactory.getInstance().createFunction();
    f.setFunctionName("NOW");
    f.setColumnName("NOW()");

    IColumn c = ASTNodeFactory.getInstance().createColumn();
    c.setColumnName("ID");

    IFilter filter = ASTNodeFactory.getInstance().createBooleanFilter();
    filter.setOperation(OPERATION.EQ);
    ((IBooleanFilter) filter).setColumn(c);
    ((IBooleanFilter) filter).setValue(f);

    QueryTreeNode qnExpected = table1.alias("T1").query(filter);
    qnExpected.build();
    assertEquals(qn, qnExpected);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:24,代码来源:SqlParserTest.java


示例13: EXISTS

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
@Test
public void testQuery_子查询_not_exist模式() throws SqlParserException {
    String sql = "SELECT * FROM TABLE1 WHERE NOT EXISTS (SELECT ID FROM TABLE2 WHERE TABLE2.NAME = TABLE1.NAME)";
    IQueryTree qc = (IQueryTree) optimizer.optimizeAndAssignment(sql, null, extraCmd, true);
    Assert.assertTrue(qc instanceof IMerge);

    IQuery query1 = (IQuery) ((IMerge) qc).getSubNodes().get(0);
    IQuery query2 = (IQuery) ((IMerge) qc).getSubNodes().get(1);

    IFunction subquery1 = (IFunction) query1.getSubqueryFilter().getArgs().get(0);
    IFunction subquery2 = (IFunction) query2.getSubqueryFilter().getArgs().get(0);
    Assert.assertTrue(subquery1 == subquery2);
    Assert.assertEquals("NOT", subquery1.getFunctionName());
    // 结构为: NOT(func) -> FILTER -> SUBQUERY_SCALAR(func) -> subquery
    Assert.assertTrue((IQuery) ((IFunction) ((IBooleanFilter) subquery1.getArgs().get(0)).getArgs().get(0)).getArgs()
        .get(0) instanceof IQuery);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:OptimizerTest.java


示例14: 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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:HbQueryHandler.java


示例15: 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;
    }

}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:30,代码来源:AbstractRangeProcessor.java


示例16: 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);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:35,代码来源:FilterUtils.java


示例17: buildColumnRefered

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private void buildColumnRefered() {
    List<ISelectable> columnRefered = new ArrayList();
    columnRefered.addAll(this.getNode().getColumnsSelected());

    for (IBooleanFilter f : this.getNode().getJoinFilter()) {
        ISelectable left = (ISelectable) f.getColumn();
        ISelectable right = (ISelectable) f.getValue();

        if (!columnRefered.contains(left)) {
            columnRefered.add(left);
        }

        if (!columnRefered.contains(right)) {
            columnRefered.add(right);
        }
    }

    for (IColumn c : this.columnInAggregate) {
        if (!columnRefered.contains(c)) {
            columnRefered.add(c);
        }
    }

    this.getNode().setColumnsRefered(columnRefered);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:26,代码来源:JoinNodeBuilder.java


示例18: addJoinOnColumns

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private void addJoinOnColumns(IFilter ifilter, JoinNode joinNode) {
    if (ifilter instanceof IBooleanFilter) {
        joinNode.addJoinFilter((IBooleanFilter) ifilter);

    } else if (ifilter instanceof ILogicalFilter) {
        ILogicalFilter ilf = (ILogicalFilter) ifilter;
        if (!ilf.getOperation().equals(OPERATION.AND)) {
            // 比如出现 A.id = B.id And ( A.id = 1 or A.name = 3)
            // 这里的or条件可直接做为other join filter
            // 如果出现 A.id = B.id OR A.name = B.name,那就是一个未知情况了
            joinNode.setOtherJoinOnFilter(ilf);
        } else {
            List<IFilter> subFilter = ilf.getSubFilter();
            if (subFilter != null) {
                for (IFilter one : subFilter) {
                    addJoinOnColumns(one, joinNode);
                }
            } else {
                throw new IllegalStateException("and has no other columns , " + ifilter);
            }
        }
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:24,代码来源:MySqlExprVisitor.java


示例19: copyFilterToJoinOnColumns

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 将连接列上的约束复制到目标节点内
 * 
 * @param DNF 要复制的DNF filter
 * @param other 要复制的目标节点
 * @param qnColumns 源节点的join字段
 * @param otherColumns 目标节点的join字段
 * @throws QueryException
 */
private static List<IFilter> copyFilterToJoinOnColumns(List<IFilter> DNF, List<ISelectable> qnColumns,
                                                       List<ISelectable> otherColumns) throws QueryException {
    List<IFilter> newIFilterToPush = new LinkedList<IFilter>();
    for (IFilter bool : DNF) {
        int index = qnColumns.indexOf(((IBooleanFilter) bool).getColumn());
        if (index >= 0) {// 只考虑在源查找,在目标查找在上一层进行控制
            IBooleanFilter o = ASTNodeFactory.getInstance().createBooleanFilter().setOperation(bool.getOperation());
            o.setColumn(otherColumns.get(index));
            if (bool.getOperation() == OPERATION.IN) {
                o.setValues(((IBooleanFilter) bool).getValues());
            } else {
                o.setValue(((IBooleanFilter) bool).getValue());
            }
            newIFilterToPush.add(o);
        }
    }

    return newIFilterToPush;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:29,代码来源:FilterPusher.java


示例20: setIntoRowSet

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
protected void setIntoRowSet(ICursorMeta cursorMetaNew, IBooleanFilter bf, IRowSet rowSet,
                             ColumnEQProcessor columnProcessor) {
    IColumn col = ExecUtils.getIColumn(bf.getColumn());
    Object val = bf.getValue();

    val = processFunction(val);
    val = columnProcessor.process(val, col.getDataType());
    Integer inte = cursorMetaNew.getIndex(col.getTableName(), col.getColumnName(), col.getAlias());

    rowSet.setObject(inte, val);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:12,代码来源:RangeMaker.java


示例21: filter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private IFilter filter(Comparable column, Comparable value, OPERATION op) {
    IBooleanFilter booleanFilter = ASTNodeFactory.getInstance().createBooleanFilter();
    booleanFilter.setColumn(ASTNodeFactory.getInstance().createColumn().setColumnName((String) column))
        .setValue(value)
        .setOperation(op);
    return booleanFilter;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:8,代码来源:FilterUtilsTest.java


示例22: 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;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:31,代码来源:FilterPreProcessor.java


示例23: getValueName

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private static String getValueName(IBooleanFilter bf, int inden, boolean needTable, boolean isIn) {
    if (bf == null) {
        return null;
    }
    if (needTable) {
        if (isIn) {
            return bf.getValues().toString();
        } else {
            if (bf.getValue() instanceof QueryTreeNode) {
                return "\n" + ((QueryTreeNode) bf.getValue()).toString(inden);
            } else {
                return bf.getValue().toString();
            }
        }
    } else {
        List args = bf.getArgs();
        if (args.size() == 2) {
            Object obj = args.get(1);
            if (obj instanceof ISelectable) {
                return ((ISelectable) obj).getColumnName();
            } else if (obj instanceof Comparable) {
                return obj.toString();
            }
        }

        return null;
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:29,代码来源:OptimizerToString.java


示例24: needToMerge

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 如果filter中包含函数,或者是绑定变量,则不进行merge
 */
private static boolean needToMerge(List<List<IFilter>> dNFNodes) {
    for (List<IFilter> DNFNode : dNFNodes) {
        for (IFilter filter : DNFNode) {
            if (((IBooleanFilter) filter).getValue() instanceof IBindVal
                || ((IBooleanFilter) filter).getValue() instanceof ISequenceVal
                || !isConstValue(((IBooleanFilter) filter).getValue())) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:17,代码来源:FilterUtils.java


示例25: 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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:FilterUtils.java


示例26: getFilterColumn

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
public static Object getFilterColumn(IFilter filter) {
    if (filter instanceof IBooleanFilter) {
        return ((IBooleanFilter) filter).getColumn();
    } else if (filter instanceof IGroupFilter) {
        return ((IGroupFilter) filter).getColumn();
    } else {
        throw new NotSupportException("LogicFilter.getColumn");
    }

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:FilterUtils.java


示例27: 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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:MySqlExprVisitor.java


示例28: 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;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:40,代码来源:BooleanFilter.java


示例29: processOneFilter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private static IFilter processOneFilter(IFilter root, boolean typeConvert) {
    if (root == null) {
        return null;
    }

    if (root instanceof IBooleanFilter) {
        return processBoolFilter(root, typeConvert);
    } else if (root instanceof ILogicalFilter) {
        ILogicalFilter lf = (ILogicalFilter) root;
        List<IFilter> children = new LinkedList<IFilter>();
        for (IFilter child : lf.getSubFilter()) {
            IFilter childProcessed = processOneFilter(child, typeConvert);
            if (childProcessed != null) {
                children.add(childProcessed);
            }
        }

        if (children.isEmpty()) {
            return null;
        }

        if (children.size() == 1) {
            return children.get(0);
        }

        lf.setSubFilter(children);
        return lf;
    }

    return root;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:32,代码来源:FilterPreProcessor.java


示例30: isFilterContainsColumnJoin

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private static boolean isFilterContainsColumnJoin(List<IFilter> DNFNode) {
    for (IFilter f : DNFNode) {
        if (f instanceof IBooleanFilter) {
            if (((IBooleanFilter) f).getColumn() instanceof IColumn
                && ((IBooleanFilter) f).getValue() instanceof IColumn) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:13,代码来源:FilterPusher.java


示例31: copy

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
public JoinNode copy() {
    JoinNode newJoinNode = new JoinNode();
    this.copySelfTo(newJoinNode);
    newJoinNode.setJoinFilter(new ArrayList<IBooleanFilter>(this.getJoinFilter()));
    newJoinNode.setJoinStrategy(this.getJoinStrategy());
    newJoinNode.setLeftNode((QueryTreeNode) this.getLeftNode().copy());
    newJoinNode.setRightNode((QueryTreeNode) this.getRightNode().copy());
    newJoinNode.setNeedOptimizeJoinOrder(this.isNeedOptimizeJoinOrder());
    newJoinNode.isCrossJoin = this.isCrossJoin;
    newJoinNode.leftOuter = this.leftOuter;
    newJoinNode.rightOuter = this.rightOuter;
    newJoinNode.usedForIndexJoinPK = this.usedForIndexJoinPK;
    return newJoinNode;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:15,代码来源:JoinNode.java


示例32: visit

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
private void visit(QueryTreeNode node) {
    if (node instanceof JoinNode) {
        List<ISelectable> leftColumns = ((JoinNode) node).getLeftKeys();
        List<ISelectable> rightColumns = ((JoinNode) node).getRightKeys();
        assert (leftColumns.size() == rightColumns.size());
        for (IFilter filter : ((JoinNode) node).getJoinFilter()) {
            addJoinFilter((IBooleanFilter) filter);
        }
    }
    for (ASTNode child : node.getChildren()) {
        visit((QueryTreeNode) child);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:14,代码来源:JoinPermutationGenerator.java


示例33: getRightKeys

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
public List<ISelectable> getRightKeys() {
    List<ISelectable> rightKeys = new ArrayList<ISelectable>(this.getJoinFilter().size());
    for (IBooleanFilter f : this.getJoinFilter()) {
        rightKeys.add((ISelectable) f.getValue());
    }
    return rightKeys;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:8,代码来源:JoinNode.java


示例34: getQueryTreeFromQueryNodes

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 构造一个join
 */
private QueryTreeNode getQueryTreeFromQueryNodes(List<QueryTreeNode> nodes) {
    if (nodes.size() == 1) {
        return nodes.get(0);
    }

    JoinNode join = null;
    for (int i = 1; i < nodes.size(); i++) {
        List<IBooleanFilter> filterToJoinOn;

        if (join == null) {
            filterToJoinOn = canJoinAndThenReturnFilters(nodes.get(i - 1), nodes.get(i));
            if (filterToJoinOn == null || filterToJoinOn.isEmpty()) {
                return null;
            }
            join = nodes.get(i - 1).join(nodes.get(i));
            join.setJoinFilter(filterToJoinOn);
        } else {
            filterToJoinOn = canJoinAndThenReturnFilters(join, nodes.get(i));
            if (filterToJoinOn == null) {
                return null;
            }
            join = join.join(nodes.get(i));
            join.setJoinFilter(filterToJoinOn);

        }

        join.build();
    }
    return join;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:34,代码来源:JoinPermutationGenerator.java


示例35: isMatchJoinFilter

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 判断是否是join条件中的一个字段,可能是左表或右边的字段
 */
private static boolean isMatchJoinFilter(List<IBooleanFilter> joinFilters, ISelectable column) {
    for (IBooleanFilter joinFilter : joinFilters) {
        ISelectable leftJoinColumn = (ISelectable) joinFilter.getColumn();
        ISelectable rightJoinColumn = (ISelectable) joinFilter.getValue();

        if (leftJoinColumn.equals(column) || rightJoinColumn.equals(column)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:DataNodeChooser.java


示例36: testFunction_to_char

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
@Test
public void testFunction_to_char() throws Exception {
    String sql = "SELECT * FROM TABLE1 T1 WHERE DATE_ADD(ID, INTERVAL 1 SECOND)= '2012-11-11'";
    QueryTreeNode qn = query(sql);
    qn.build();

    TableNode table1 = new TableNode("TABLE1");

    IFunction f = ASTNodeFactory.getInstance().createFunction();
    f.setFunctionName("DATE_ADD");

    IColumn c = ASTNodeFactory.getInstance().createColumn();
    c.setColumnName("ID");
    List args = new ArrayList();
    args.add(c);
    args.add("INTERVAL 1 SECOND");
    f.setArgs(args);

    f.setColumnName("DATE_ADD(ID, INTERVAL 1 SECOND)");
    IFilter filter = ASTNodeFactory.getInstance().createBooleanFilter();
    filter.setOperation(OPERATION.EQ);
    ((IBooleanFilter) filter).setColumn(f);
    ((IBooleanFilter) filter).setValue("2012-11-11");

    QueryTreeNode qnExpected = table1.alias("T1").query(filter);
    qnExpected.build();
    assertEquals(qn, qnExpected);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:29,代码来源:SqlParserTest.java


示例37: containsColumnsReferedForParent

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入依赖的package包/类
/**
 * 列的tablename会设为表别名
 * 
 * @return
 */
public boolean containsColumnsReferedForParent(ISelectable c) {
    if (c instanceof IBooleanFilter) {
        if (((IBooleanFilter) c).getOperation().equals(OPERATION.CONSTANT)) {
            return true;
        }
    }

    return this.getColumnsReferedForParent().contains(c);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:15,代码来源:QueryTreeNode.java



注:本文中的com.taobao.tddl.optimizer.core.expression.IBooleanFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。