本文整理汇总了Java中com.taobao.tddl.optimizer.config.table.TableMeta类的典型用法代码示例。如果您正苦于以下问题:Java TableMeta类的具体用法?Java TableMeta怎么用?Java TableMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableMeta类属于com.taobao.tddl.optimizer.config.table包,在下文中一共展示了TableMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultSetMetaToSchema
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
public static TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaData dbmd,
String logicalTableName, String actualTableName) {
String xml = resultSetMetaToSchemaXml(rsmd, dbmd, logicalTableName, actualTableName);
if (xml == null) {
return null;
}
TableMetaParser tableParser = new MysqlTableMetaParser();
xml = xml.replaceFirst("<tables>", xmlHead);
List<TableMeta> schemaList = tableParser.parse(xml);
if (!schemaList.isEmpty()) {
return schemaList.get(0);
}
return null;
}
示例2: getTable0
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
private TableMeta getTable0(String tableName) {
TargetDB targetDB = rule.shardAny(tableName);
TableMeta ts = null;
if (targetDB.getDbIndex() == null) {
// 没有对应的规则,也没有default group,则可能是一个不存在的表
// 尝试找一下local
ts = local.getTable(tableName);
} else {
Group group = matrix.getGroup(targetDB.getDbIndex()); // 先找到group
if (group == null) {
throw new TddlRuntimeException(ErrorCode.ERR_CONFIG, "not found groupName : " + targetDB.getDbIndex());
}
try {
ts = repos.get(group).getTable(tableName, targetDB.getTableNames().iterator().next());
} catch (ExecutionException e) {
logger.error(ErrorCode.ERR_CONFIG.getMessage("not found table : " + tableName), e);
}
}
return ts;
}
示例3: findBestIndexByAllColumnsSelected
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
/**
* 根据查询字段,查找一个索引包含所有选择列,并且包含的无关列最少则选择该索引
*/
public static IndexMeta findBestIndexByAllColumnsSelected(TableMeta tableMeta, List<ISelectable> queryColumns,
Map<String, Object> extraCmd) {
if (!chooseIndex(extraCmd)) {
return null;
}
IndexMeta indexChoosed = null;
int theLeastColumnsNumber = Integer.MAX_VALUE;
List<IndexMeta> indexs = tableMeta.getIndexs();
for (int i = 0; i < indexs.size(); i++) {
List<ISelectable> indexColumns = OptimizerUtils.columnMetaListToIColumnList(indexs.get(i).getKeyColumns());
if (indexColumns.containsAll(queryColumns)) {
if (theLeastColumnsNumber > indexs.get(i).getKeyColumns().size()) {
theLeastColumnsNumber = indexs.get(i).getKeyColumns().size();
indexChoosed = indexs.get(i);
}
}
}
return indexChoosed;
}
示例4: getTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public ITable getTable(TableMeta table_schema, String groupNode, String actualTableName) throws TddlException {
ITable table = tables.get(table_schema.getTableName());
if (table == null) {
synchronized (this) {
table = tables.get(table_schema.getTableName());
if (table == null) {
try {
table = initTable(table_schema);
} catch (ReplicaWriteException ex) {
throw new TddlNestableRuntimeException(ex);
}
if (!table_schema.isTmp()) {
tables.put(table_schema.getTableName(), table);
}
}
}
}
return table;
}
示例5: HbCursor
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
public HbCursor(IndexMeta indexMeta, HbOperate hbOperate, TablePhysicalSchema physicalSchema, TableMeta schema,
IQuery query){
this.indexMeta = indexMeta;
this.cursorMeta = ExecUtils.convertToICursorMeta(this.indexMeta);
this.columnMap = new HashMap<String, ColumnMeta>();
this.columnIndex = new HashMap<String, Integer>();
for (ColumnMeta cm : cursorMeta.getColumns()) {
columnMap.put(cm.getName(), cm);
Integer index = cursorMeta.getIndex(indexMeta.getTableName(), cm.getName(), cm.getAlias());
columnIndex.put(cm.getName(), index);
}
this.hbOperate = hbOperate;
this.physicalSchema = physicalSchema;
this.schema = schema;
this.query = query;
}
示例6: resultSetMetaToSchema
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
public static TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaData dbmd,
String logicalTableName, String actualTableName) {
String xml = resultSetMetaToSchemaXml(rsmd, dbmd, logicalTableName, actualTableName);
if (xml == null) {
return null;
}
xml = xml.replaceFirst("<tables>", xmlHead);
List<TableMeta> ts = null;
ts = TableMetaParser.parse(xml);
if (ts != null && !ts.isEmpty()) {
return ts.get(0);
}
return null;
}
示例7: getTable0
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
public TableMeta getTable0(String tableName) {
TargetDB targetDB = rule.shardAny(tableName);
TableMeta ts = null;
if (targetDB.getDbIndex() == null) {
// 没有对应的规则,也没有default group,则可能是一个不存在的表
// 尝试找一下local
ts = local.getTable(tableName);
} else {
Group group = matrix.getGroup(targetDB.getDbIndex()); // 先找到group
try {
ts = repos.get(group).getTable(tableName, targetDB.getTableNames().iterator().next());
} catch (ExecutionException e) {
throw new OptimizerException(e);
}
}
if (ts == null) {
throw new TddlRuntimeException(tableName + " is not found");
}
return ts;
}
示例8: getTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public ITable getTable(TableMeta table_schema, String groupNode) throws TddlException {
ITable table = tables.get(table_schema.getTableName());
if (table == null) {
synchronized (this) {
table = tables.get(table_schema.getTableName());
if (table == null) {
try {
table = initTable(table_schema);
} catch (ReplicaWriteException ex) {
throw new TddlException(ExceptionErrorCodeUtils.Read_only, ex);
}
if (!table_schema.isTmp()) {
tables.put(table_schema.getTableName(), table);
}
}
}
}
return table;
}
示例9: nestBuildTableAndSchema
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
/**
* 准备indexMeta和ITable信息
*
* @param tableAndIndex
*/
protected void nestBuildTableAndSchema(String groupDataNode, TableAndIndex tableAndIndex,
ExecutionContext executionContext, String indexName, String actualTable,
boolean logicalIndex) throws TddlException {
if (indexName != null && !"".equals(indexName)) {
String tableName = ExecUtils.getLogicTableName(indexName);
TableMeta ts = getTableMeta(tableName);
tableAndIndex.index = ts.getIndexMeta(indexName);
tableAndIndex.table = executionContext.getCurrentRepository().getTable(ts, groupDataNode, actualTable);
}
}
示例10: getTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public ITable getTable(final TableMeta meta, final String groupNode, String actualTableName) throws TddlException {
if (meta.isTmp()) {
return getTempTable(meta);
} else {
try {
return tables.get(groupNode).get(meta);
} catch (ExecutionException e) {
throw new TddlNestableRuntimeException(e);
}
}
}
示例11: doInit
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
protected void doInit() throws TddlException {
super.doInit();
if (local != null) {
local.init();
}
repos = CacheBuilder.newBuilder().build(new CacheLoader<Group, RepoSchemaManager>() {
@Override
public RepoSchemaManager load(Group group) throws Exception {
RepoSchemaManager repo = new RepoSchemaManager();
repo.setGroup(group);
repo.setLocal(local);
repo.setRule(rule);
repo.init();
return repo;
}
});
cache = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(cacheExpireTime, TimeUnit.MILLISECONDS)
.build(new CacheLoader<String, TableMeta>() {
@Override
public TableMeta load(String tableName) throws Exception {
return getTable0(tableName);
}
});
}
示例12: getTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public TableMeta getTable(String tableName) {
// if (tableName.equals(DUAL)) {
// return buildDualTable();
// }
TableMeta meta = null;
if (local != null) {// 本地如果开启了,先找本地
meta = local.getTable(tableName);
}
if (meta != null) {
return meta;
}
if (useCache) {
try {
meta = cache.get(tableName);
} catch (Throwable e) {
throw new TddlRuntimeException(ErrorCode.ERR_CONFIG, e, "not found table : " + tableName);
}
} else {
meta = this.getTable0(tableName);
}
return meta;
}
示例13: putTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public void putTable(String tableName, TableMeta tableMeta) {
if (local != null) {
local.putTable(tableName, tableMeta);
} else if (useCache) {
cache.put(tableName, tableMeta);
}
}
示例14: getAllTables
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
@Override
public Collection<TableMeta> getAllTables() {
List<TableMeta> metas = new ArrayList();
if (local != null) {
metas.addAll(local.getAllTables());
}
if (cache != null) {
metas.addAll(cache.asMap().values());
}
return metas;
}
示例15: buildDualTable
import com.taobao.tddl.optimizer.config.table.TableMeta; //导入依赖的package包/类
protected TableMeta buildDualTable() {
IndexMeta index = new IndexMeta(SchemaManager.DUAL,
new ArrayList<ColumnMeta>(),
new ArrayList<ColumnMeta>(),
IndexType.NONE,
Relationship.NONE,
false,
true);
return new TableMeta(DUAL, new ArrayList<ColumnMeta>(), index, new ArrayList<IndexMeta>());
}