當前位置: 首頁>>代碼示例>>Java>>正文


Java ICursorMeta.getIndex方法代碼示例

本文整理匯總了Java中com.taobao.tddl.executor.cursor.ICursorMeta.getIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java ICursorMeta.getIndex方法的具體用法?Java ICursorMeta.getIndex怎麽用?Java ICursorMeta.getIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.taobao.tddl.executor.cursor.ICursorMeta的用法示例。


在下文中一共展示了ICursorMeta.getIndex方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getObject

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
public static Object getObject(final ICursorMeta meta, IRowSet rowSet, String tableName, String columnName,
                               String columnAlias) {
    Integer index = meta.getIndex(tableName, columnName, columnAlias);
    if (index == null) {
        throw new RuntimeException("not found :" + tableName + "." + columnName + " in ICursorMeta:" + meta);
    }
    return rowSet.getObject(index);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:9,代碼來源:ExecUtils.java

示例2: addIndexToNewIndexes

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
private void addIndexToNewIndexes(ICursorMeta cursorMeta, List<ColumnMeta> columns, List<Integer> indexes,
                                  int offset) {
    for (ColumnMeta cm : columns) {
        Integer index = cursorMeta.getIndex(cm.getTableName(), cm.getName(), cm.getAlias());

        indexes.add(offset + index);
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:9,代碼來源:JoinSchematicCursor.java

示例3: getObject

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
public static Object getObject(final ICursorMeta meta, IRowSet rowSet, String tableName, String columnName) {
    Integer index = meta.getIndex(tableName, columnName);
    if (index == null) {
        throw new RuntimeException("在meta中沒找到該列:" + tableName + "." + columnName + " ICursorMeta:" + meta);
    }
    return rowSet.getObject(index);
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:8,代碼來源:ExecUtils.java

示例4: addIndexToNewIndexes

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
private void addIndexToNewIndexes(ICursorMeta cursorMeta, List<ColumnMeta> columns, List<Integer> indexes,
                                  int offset) {
    for (ColumnMeta cm : columns) {
        Integer index = cursorMeta.getIndex(cm.getTableName(), cm.getName());
        if (index == null) {
            index = cursorMeta.getIndex(cm.getTableName(), cm.getAlias());
        }
        indexes.add(offset + index);
    }
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:11,代碼來源:JoinSchematicCursor.java

示例5: initAliasSchema

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
private void initAliasSchema(List<ISelectable> retColumns, String tableAlias, ICursorMeta cursormeta)
                                                                                                     throws TddlException {
    if (schemaInited) {
        return;
    }
    colMessages = new ArrayList<ColumnMeta>(retColumns.size());
    List<Integer> indexes = new ArrayList<Integer>(colMessages.size());
    for (ISelectable col : retColumns) {
        ColumnMeta cm = null;
        String tableName = col.getTableName();
        if (tableAlias != null) {
            if (tableName == null || tableAlias.startsWith(tableName)) {
                // 如果以tableName作為開始,那麽認為認為是相同名字,因此也做截斷處理,取alias的.之前的數據。
                // 最好也讓優化器協助,不允許在alias裏麵出現"."
                tableAlias = ExecUtils.getLogicTableName(tableAlias);
            }
        }
        if (!TStringUtil.isBlank(col.getAlias())) {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col, col.getAlias());
            } else {
                cm = ExecUtils.getColumnMeta(col, tableAlias, col.getAlias());
            }
        } else {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col);
            } else {
                cm = ExecUtils.getColumnMetaTable(col, tableAlias);
            }
        }
        Integer index = cursormeta.getIndex(col.getTableName(), col.getColumnName(), col.getAlias());

        if (index != null) {
            indexes.add(index);
            colMessages.add(cm);
        }
    }
    if (!TStringUtil.isBlank(tableAlias)) {
        // 如果沒有就用下層的tableName
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
        List<IOrderBy> obOld = getOrderBy();
        if (obOld != null) {
            List<IOrderBy> obNew = new ArrayList<IOrderBy>(obOld.size());
            for (IOrderBy orderBy : obOld) {
                IColumn icol = ExecUtils.getIColumn(orderBy.getColumn());
                IColumn icolNew = icol.copy();
                obNew.add(ASTNodeFactory.getInstance()
                    .createOrderBy()
                    .setColumn(icolNew.setTableName(tableAlias).setAlias(null))
                    .setDirection(orderBy.getDirection()));
            }
            setOrderBy(obNew);
        }
    } else {
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
    }
    schemaInited = true;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:59,代碼來源:ColumnAliasCursor.java

示例6: getActualIndex

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
/**
 * @param logicalIndex 用戶select時的index
 * @return IRowSet中實際的index
 * @throws SQLException
 */
private int getActualIndex(int logicalIndex) {
    if (this.logicalIndexToActualIndex == null) {
        logicalIndexToActualIndex = new HashMap<Integer, Integer>();
        isLoigcalIndexEqualActualIndex = true;
        if (this.currentKVPair == null) {
            return logicalIndex;
        }

        ICursorMeta cm = currentKVPair.getParentCursorMeta();
        if (cm.isSureLogicalIndexEqualActualIndex()) {
            // 如果確定相等,就不需要挨個去判斷了
            isLoigcalIndexEqualActualIndex = true;
        } else {
            try {
                for (int i = 0; i < this.getMetaData().getColumnCount(); i++) {
                    ColumnMeta ic = this.getMetaData().getColumnMetas().get(i);
                    @SuppressWarnings("unused")
                    String name = ic.getName();
                    String tableName = ic.getTableName();
                    Integer indexInCursorMeta = null;

                    // 要以別名優先

                    indexInCursorMeta = cm.getIndex(tableName, ic.getName(), ic.getAlias());
                    if (indexInCursorMeta == null) {
                        throw new TddlNestableRuntimeException("impossible");
                    }
                    logicalIndexToActualIndex.put(i, indexInCursorMeta);
                    if (i != indexInCursorMeta) {
                        isLoigcalIndexEqualActualIndex = false;
                    }
                }
            } catch (SQLException e) {
                throw new TddlNestableRuntimeException(e);
            }
        }
    }

    if (isLoigcalIndexEqualActualIndex) {
        return logicalIndex;
    } else {
        Integer actualIndex = logicalIndexToActualIndex.get(logicalIndex);
        return actualIndex;
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:51,代碼來源:TResultSet.java

示例7: initAliasSchema

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
private void initAliasSchema(List<ISelectable> retColumns, String tableAlias, ICursorMeta cursormeta) {
    if (schemaInited) {
        return;
    }
    colMessages = new ArrayList<ColumnMeta>(retColumns.size());
    List<Integer> indexes = new ArrayList<Integer>(colMessages.size());
    for (ISelectable col : retColumns) {
        ColumnMeta cm = null;
        String tableName = col.getTableName();
        if (tableAlias != null) {
            if (tableName == null || tableAlias.startsWith(tableName)) {
                // 如果以tableName作為開始,那麽認為認為是相同名字,因此也做截斷處理,取alias的.之前的數據。
                // 最好也讓優化器協助,不允許在alias裏麵出現"."
                tableAlias = ExecUtils.getLogicTableName(tableAlias);
            }
        }
        if (!TStringUtil.isBlank(col.getAlias())) {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col, col.getAlias());
            } else {
                cm = ExecUtils.getColumnMeta(col, tableAlias, col.getAlias());
            }
        } else {
            if (TStringUtil.isBlank(tableAlias)) {
                cm = ExecUtils.getColumnMeta(col);
            } else {
                cm = ExecUtils.getColumnMetaTable(col, tableAlias);
            }
        }
        Integer index = cursormeta.getIndex(col.getTableName(), col.getColumnName());
        if (index == null) {
            index = cursormeta.getIndex(col.getTableName(), col.getAlias());
        }

        if (index != null) {
            indexes.add(index);
            colMessages.add(cm);
        }
    }
    if (!TStringUtil.isBlank(tableAlias)) {
        // 如果沒有就用下層的tableName
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
        List<IOrderBy> obOld = getOrderBy();
        if (obOld != null) {
            List<IOrderBy> obNew = new ArrayList<IOrderBy>(obOld.size());
            for (IOrderBy orderBy : obOld) {
                IColumn icol = ExecUtils.getIColumn(orderBy.getColumn());
                IColumn icolNew = icol.copy();
                obNew.add(ASTNodeFactory.getInstance()
                    .createOrderBy()
                    .setColumn(icolNew.setTableName(tableAlias).setAlias(null))
                    .setDirection(orderBy.getDirection()));
            }
            setOrderBy(obNew);
        }
    } else {
        newMeta = CursorMetaImp.buildNew(colMessages, indexes, cursormeta.getIndexRange());
    }
    schemaInited = true;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:61,代碼來源:ColumnAliasCursor.java

示例8: getActualIndex

import com.taobao.tddl.executor.cursor.ICursorMeta; //導入方法依賴的package包/類
/**
 * @param logicalIndex 用戶select時的index
 * @return IRowSet中實際的index
 * @throws SQLException
 */
private int getActualIndex(int logicalIndex) {
    if (this.logicalIndexToActualIndex == null) {
        logicalIndexToActualIndex = new HashMap<Integer, Integer>();
        isLoigcalIndexEqualActualIndex = true;
        if (this.currentKVPair == null) {
            return logicalIndex;
        }

        ICursorMeta cm = currentKVPair.getParentCursorMeta();
        if (cm.isSureLogicalIndexEqualActualIndex()) {
            // 如果確定相等,就不需要挨個去判斷了
            isLoigcalIndexEqualActualIndex = true;
        } else {
            try {
                for (int i = 0; i < this.getMetaData().getColumnCount(); i++) {
                    ColumnMeta ic = this.getMetaData().getColumnMetas().get(i);
                    String name = ic.getName();
                    String tableName = ic.getTableName();
                    Integer indexInCursorMeta = cm.getIndex(tableName, name);

                    if (indexInCursorMeta == null && ic.getAlias() != null) {
                        indexInCursorMeta = cm.getIndex(tableName, ic.getAlias());
                    }

                    if (indexInCursorMeta == null) {
                        throw new TddlRuntimeException("不可能出現");
                    }
                    logicalIndexToActualIndex.put(i, indexInCursorMeta);
                    if (i != indexInCursorMeta) {
                        isLoigcalIndexEqualActualIndex = false;
                    }
                }
            } catch (SQLException e) {
                throw new TddlRuntimeException(e);
            }
        }
    }

    if (isLoigcalIndexEqualActualIndex) {
        return logicalIndex;
    } else {
        Integer actualIndex = logicalIndexToActualIndex.get(logicalIndex);
        return actualIndex;
    }
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:51,代碼來源:TResultSet.java


注:本文中的com.taobao.tddl.executor.cursor.ICursorMeta.getIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。