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


Java OPERATION类代码示例

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


OPERATION类属于com.taobao.tddl.optimizer.core.expression.IFilter包,在下文中一共展示了OPERATION类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: manageToBooleanRangeCursor

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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.IFilter.OPERATION; //导入依赖的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: InCursor

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
public InCursor(Cursor cursor, List<IOrderBy> orderBys, IColumn c, List<Object> v, OPERATION op){
    super(cursor, null, orderBys);
    keyCodec = CodecFactory.getInstance(CodecFactory.FIXED_LENGTH)
        .getCodec(Arrays.asList(ExecUtils.getColumnMeta(c)));
    this.c = c;

    // if (c.getDataType() == DATA_TYPE.DATE_VAL) {
    // List<Object> vNew = new ArrayList<Object>(v.size());
    // for (Object comp : v) {
    // vNew.add(new Date((Long) comp));
    // }
    // v = vNew;
    // }
    this.valuesToFind = v;
    this.op = op;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:17,代码来源:InCursor.java

示例4: toDNF

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
/**
 * 将一个Bool树转换成析取形式 A(B+C)转换为AB+AC,不做拉平处理
 */
public static IFilter toDNF(IFilter node) {
    if (node == null) {
        return null;
    }

    while (!isDNF(node)) {
        if (node.getOperation().equals(OPERATION.OR)) {
            node = passOrNode((ILogicalFilter) node);
        } else if (node.getOperation().equals(OPERATION.AND)) {
            node = expandAndNode((ILogicalFilter) node);
        }
    }

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

示例5: toDNFNodesArray

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
/**
 * 将一个IFilter全部展开为一个多维数组,会做拉平处理,需要预先调用toDNF/toDNFAndFlat进行预处理转化为DNF范式
 * 
 * <pre>
 * 比如:(A and B) or (A and C)
 * 返回结果为: 
 *   List- 
 *      List 
 *         -(A , B)
 *      List
 *         -(A , C)
 * </pre>
 */
public static List<List<IFilter>> toDNFNodesArray(IFilter node) {
    if (node == null || !isDNF(node)) {
        return Lists.newLinkedList(); // 返回空的数组节点
    }

    List<List<IFilter>> res = new LinkedList();
    if (node.getOperation().equals(OPERATION.OR)) {
        for (int i = 0; i < ((ILogicalFilter) node).getSubFilter().size(); i++) {
            res.addAll(toDNFNodesArray(((ILogicalFilter) node).getSubFilter().get(i)));
        }
    } else if (node.getOperation().equals(OPERATION.AND)) {
        res.add(toDNFNode(node));
    } else {
        List<IFilter> DNFNode = new ArrayList<IFilter>(1);
        DNFNode.add(node);
        res.add(DNFNode);
    }

    if (res == null || res.isEmpty() || res.get(0) == null || res.get(0).isEmpty() || res.get(0).get(0) == null) {
        return new LinkedList<List<IFilter>>();
    } else {
        return res;
    }

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

示例6: addResultFilter

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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

示例7: or

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
/**
 * 创建or条件
 */
public static IFilter or(IFilter root, IFilter o) {

    // 相等的情况下就不合并了
    if (root == o) {
        return root;
    }
    if (o == null) {
        return root;
    }

    if (root == null) {
        root = o;
    } else {
        if (root.getOperation().equals(OPERATION.OR)) {
            ((ILogicalFilter) root).addSubFilter(o);
        } else {
            ILogicalFilter and = ASTNodeFactory.getInstance().createLogicalFilter().setOperation(OPERATION.OR);
            and.addSubFilter(root);
            and.addSubFilter(o);
            root = and;
        }
    }
    return root;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:28,代码来源:FilterUtils.java

示例8: visit

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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

示例9: addJoinOnColumns

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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:loye168,项目名称:tddl5,代码行数:24,代码来源:MySqlExprVisitor.java

示例10: findBooleanFilter

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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

示例11: testFunction_noArgs

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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

示例12: manageToBooleanRangeCursor

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的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

示例13: isCNFNode

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
/**
 * 是否为一简单合取式
 */
public static boolean isCNFNode(IFilter node) {
    if (node == null) {
        return false;
    }

    if (node.getOperation().equals(OPERATION.AND)) {
        for (IFilter f : ((ILogicalFilter) node).getSubFilter())
            if (!isCNFNode(f)) {
                return false;
            }

    } else if (node.getOperation().equals(OPERATION.OR)) {
        return false;
    }

    return true;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:21,代码来源:FilterUtils.java

示例14: or

import com.taobao.tddl.optimizer.core.expression.IFilter.OPERATION; //导入依赖的package包/类
/**
 * 创建or条件
 */
public static IFilter or(IFilter root, IFilter o) {
    if (o == null) {
        return root;
    }

    if (root == null) {
        root = o;
    } else {
        if (root.getOperation().equals(OPERATION.OR)) {
            ((ILogicalFilter) root).addSubFilter(o);
        } else {
            ILogicalFilter and = ASTNodeFactory.getInstance().createLogicalFilter().setOperation(OPERATION.OR);
            and.addSubFilter(root);
            and.addSubFilter(o);
            root = and;
        }
    }
    return root;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:23,代码来源:FilterUtils.java

示例15: visit

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

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

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

    MySqlExprVisitor rv = new MySqlExprVisitor();
    third.accept(rv);
    Comparable 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:beebeandwer,项目名称:TDDL,代码行数:27,代码来源:MySqlExprVisitor.java


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