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


Java TableMeta类代码示例

本文整理汇总了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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:17,代码来源:MysqlTableMetaManager.java

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

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

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

示例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;

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

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

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

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

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

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

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

            }
        });
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:33,代码来源:RuleSchemaManager.java

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

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

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

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


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