当前位置: 首页>>代码示例>>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类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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