本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}