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


Java IBooleanFilter.getColumn方法代码示例

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


在下文中一共展示了IBooleanFilter.getColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

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

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

示例4: getJoinKeysWithColumnJoin

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
 * 找到join的列条件的所有列信息,必须是a.id=b.id的情况,针对a.id=1返回为null
 */
private static ISelectable[] getJoinKeysWithColumnJoin(IBooleanFilter filter) {
    if (filter.getColumn() instanceof IColumn && filter.getValue() instanceof IColumn) {
        if (OPERATION.EQ.equals(filter.getOperation())) {
            return new ISelectable[] { (ISelectable) filter.getColumn(), (ISelectable) filter.getValue() };
        }
    }

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

示例5: 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

示例6: 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:loye168,项目名称:tddl5,代码行数:40,代码来源:BooleanFilter.java

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

示例8: 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

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

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

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

示例12: getColumn

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
protected ISelectable getColumn(IBooleanFilter f) {
    return (ISelectable) f.getColumn();
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:4,代码来源:AbstractRangeProcessor.java

示例13: buildJoinKeys

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
private void buildJoinKeys() {
    if (this.getNode().isUedForIndexJoinPK()) {
        return;
    }
    List<IBooleanFilter> otherJoinOnFilters = new ArrayList(this.getNode().getJoinFilter().size());
    for (IBooleanFilter f : this.getNode().getJoinFilter()) {
        ISelectable leftKey = null;
        if (f.getColumn() != null && f.getColumn() instanceof ISelectable) {
            leftKey = this.getColumnFromOtherNode((ISelectable) f.getColumn(), this.getNode().getLeftNode());
        }

        ISelectable rightKey = null;
        if (f.getValue() != null && f.getValue() instanceof ISelectable) {
            rightKey = this.getColumnFromOtherNode((ISelectable) f.getValue(), this.getNode().getRightNode());
        }

        // 可能顺序调换了,重新找一次
        if (leftKey == null || rightKey == null) {
            if (f.getValue() != null && f.getValue() instanceof ISelectable) {
                leftKey = this.getColumnFromOtherNode((ISelectable) f.getValue(), this.getNode().getLeftNode());
            }

            if (f.getColumn() != null && f.getColumn() instanceof ISelectable) {
                rightKey = this.getColumnFromOtherNode((ISelectable) f.getColumn(), this.getNode().getRightNode());
            }
        }

        if (leftKey == null || rightKey == null) {
            // 可能有以下情况
            // id=1,s.id=s.key_id
            IFilter otherJoinOnFilter = this.getNode().getOtherJoinOnFilter();
            otherJoinOnFilter = FilterUtils.and(otherJoinOnFilter, f);
            this.getNode().setOtherJoinOnFilter(otherJoinOnFilter);
            otherJoinOnFilters.add(f);
            continue;
        }

        /**
         * 如果是回表操作,不能把索引的joinKey添加到temp中,否则如果有merge,这个列会被加到sql的select中,
         * 而导致找不到列
         */
        if (!this.getNode().isUedForIndexJoinPK()) {
            f.setColumn(buildSelectable(leftKey));
            f.setValue(buildSelectable(rightKey));
        }

    }

    this.getNode().getJoinFilter().removeAll(otherJoinOnFilters);
    this.buildFilter(this.getNode().getOtherJoinOnFilter(), false);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:52,代码来源:JoinNodeBuilder.java

示例14: estimateRowCount

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
 * 根据索引和查询的filter条件,估算记录数
 * 
 * @param tableRowCount 表记录数
 * @param filters 查询条件
 * @param index 选择的索引
 * @param indexStat 索引的统计信息,如果为null则按照经验值预算
 * @return
 */
public static long estimateRowCount(long tableRowCount, List<IFilter> filters, IndexMeta index,
                                    KVIndexStat indexStat) {
    // indexMeta
    if (filters == null || filters.isEmpty()) {
        return tableRowCount;
    }

    Map<String, Double> columnAndColumnCountItSelectivity = new HashMap();
    if (index != null && indexStat != null) {
        Double columnCountEveryKeyColumnSelect = (index.getKeyColumns().size())
                                                 * (1.0 / indexStat.getDistinctKeys());
        for (ColumnMeta cm : index.getKeyColumns()) {
            columnAndColumnCountItSelectivity.put(cm.getName(), columnCountEveryKeyColumnSelect);
        }
    }

    long count = tableRowCount;
    // 每出现一个运算符,都把现在的行数乘上一个系数
    for (IFilter f : filters) {
        if (f == null) {
            break;
        }

        if (f instanceof IGroupFilter) {
            continue;
        }

        IBooleanFilter filter = (IBooleanFilter) f;
        Double selectivity = null;
        if (filter.getColumn() instanceof IColumn) {
            String columnName = ((IColumn) filter.getColumn()).getColumnName();
            if (columnAndColumnCountItSelectivity.containsKey(columnName)) {
                selectivity = columnAndColumnCountItSelectivity.get(columnName);
            }
        }

        if (selectivity == null) {
            selectivity = CostEsitimaterFactory.selectivity(filter.getOperation());
        }

        count *= selectivity;
    }
    return count;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:54,代码来源:CostEsitimaterFactory.java

示例15: estimateRowCount

import com.taobao.tddl.optimizer.core.expression.IBooleanFilter; //导入方法依赖的package包/类
/**
 * 根据索引和查询的filter条件,估算记录数
 * 
 * @param tableRowCount 表记录数
 * @param filters 查询条件
 * @param index 选择的索引
 * @param indexStat 索引的统计信息,如果为null则按照经验值预算
 * @return
 */
public static long estimateRowCount(long tableRowCount, List<IFilter> filters, IndexMeta index,
                                    KVIndexStat indexStat) {
    // indexMeta
    if (filters == null || filters.isEmpty()) {
        return tableRowCount;
    }

    Map<String, Double> columnAndColumnCountItSelectivity = new HashMap();
    if (index != null && indexStat != null) {
        Double columnCountEveryKeyColumnSelect = ((double) index.getKeyColumns().size())
                                                 * (1.0 / indexStat.getDistinctKeys());
        for (ColumnMeta cm : index.getKeyColumns()) {
            columnAndColumnCountItSelectivity.put(cm.getName(), columnCountEveryKeyColumnSelect);
        }
    }

    long count = tableRowCount;
    // 每出现一个运算符,都把现在的行数乘上一个系数
    for (IFilter f : filters) {
        if (f == null) {
            break;
        }

        IBooleanFilter filter = (IBooleanFilter) f;
        Double selectivity = null;
        if (filter.getColumn() instanceof IColumn) {
            String columnName = ((IColumn) filter.getColumn()).getColumnName();
            if (columnAndColumnCountItSelectivity.containsKey(columnName)) {
                selectivity = columnAndColumnCountItSelectivity.get(columnName);
            }
        }

        if (selectivity == null) {
            selectivity = CostEsitimaterFactory.selectivity(filter.getOperation());
        }

        count *= selectivity;
    }
    return count;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:50,代码来源:CostEsitimaterFactory.java


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