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


Java TableMetaParser类代码示例

本文整理汇总了Java中com.taobao.tddl.optimizer.config.table.parse.TableMetaParser的典型用法代码示例。如果您正苦于以下问题:Java TableMetaParser类的具体用法?Java TableMetaParser怎么用?Java TableMetaParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TableMetaParser类属于com.taobao.tddl.optimizer.config.table.parse包,在下文中一共展示了TableMetaParser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resultSetMetaToSchema

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的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: resultSetMetaToSchema

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的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

示例3: parseSchema

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
public static StaticSchemaManager parseSchema(InputStream in) throws TddlException {
    if (in == null) {
        throw new IllegalArgumentException("in is null");
    }

    try {
        StaticSchemaManager schemaManager = new StaticSchemaManager();
        schemaManager.init();
        List<TableMeta> schemaList = TableMetaParser.parse(in);
        for (TableMeta t : schemaList) {
            schemaManager.putTable(t.getTableName(), t);
        }
        return schemaManager;
    } finally {
        IOUtils.closeQuietly(in);
    }

}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:19,代码来源:StaticSchemaManager.java

示例4: buildReturnColumns

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
void buildReturnColumns() throws TddlException {
    if (returnColumns != null) {
        return;
    }

    returnColumns = new ArrayList();

    // 使用meta做为returncolumns
    // resultset中返回的meta信是物理表名,会导致join在构造返回对象时找不到index(表名不同/为null)
    if (meta != null) {
        returnColumns.addAll(meta.getColumns());
    } else {
        try {
            if (this.myJdbcHandler.getResultSet() == null) {
                myJdbcHandler.executeQuery(meta, isStreaming);
            }

            ResultSetMetaData rsmd = this.myJdbcHandler.getResultSet().getMetaData();
            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                boolean isUnsigned = StringUtils.containsIgnoreCase(rsmd.getColumnTypeName(i), "unsigned");
                DataType type = TableMetaParser.jdbcTypeToDataType(rsmd.getColumnType(i), isUnsigned);
                String name = rsmd.getColumnLabel(i);
                ColumnMeta cm = new ColumnMeta(null, name, type, null, true);
                returnColumns.add(cm);
            }

            meta = CursorMetaImp.buildNew(returnColumns);
            myJdbcHandler.setContext(meta, isStreaming);
        } catch (Exception e) {
            throw new TddlException(e);
        }
    }

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

示例5: loadDualTable

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
void loadDualTable() throws TddlException {
    ConfigDataHandler cdh = ConfigDataHandlerCity.getFileFactory(appName).getConfigDataHandler("DUAL_TABLE.xml",
        null);
    String data = cdh.getData();

    cdh.destroy();
    TableMetaParser parser = new TableMetaParser();

    TableMeta dualTable = parser.parse(data).get(0);

    this.putTable(dualTable.getTableName(), dualTable);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:13,代码来源:StaticSchemaManager.java

示例6: testSimple

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
@Test
public void testSimple() {
    List<TableMeta> schemaList = new TableMetaParser().parse(Thread.currentThread()
        .getContextClassLoader()
        .getResourceAsStream("config/test_table.xml"));
    System.out.println(schemaList);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:8,代码来源:TableMetaParserTest.java

示例7: init

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
public void init() throws TddlException {
    if (inited) {
        return;
    }
    try {
        myJdbcHandler.executeQuery(meta, isStreaming);
        // ResultSetMetaData rsmd =
        // this.myJdbcHandler.getResultSet().getMetaData();
        returnColumns = new ArrayList();
        // 使用meta做为returncolumns
        // resultset中返回的meta信是物理表名,会导致join在构造返回对象时找不到index(表名不同/为null)
        if (meta != null) {
            returnColumns.addAll(meta.getColumns());
        } else {
            ResultSetMetaData rsmd = this.myJdbcHandler.getResultSet().getMetaData();
            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                DataType type = TableMetaParser.jdbcTypeToDataType(rsmd.getColumnType(i));
                String name = rsmd.getColumnLabel(i);
                ColumnMeta cm = new ColumnMeta(null, name, type, null, true);
                returnColumns.add(cm);
            }

            meta = CursorMetaImp.buildNew(returnColumns);
            myJdbcHandler.setContext(meta, isStreaming);
        }
        inited = true;
    } catch (SQLException e) {
        throw new TddlException(e);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:31,代码来源:My_Cursor.java

示例8: onDataRecieved

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
@Override
public void onDataRecieved(String dataId, String data) {
    if (data == null || data.isEmpty()) {
        logger.warn("schema is null, dataId is " + dataId);
        return;
    }

    InputStream sis = null;
    try {
        sis = new ByteArrayInputStream(data.getBytes());
        List<TableMeta> schemaList = TableMetaParser.parse(sis);

        schemaManager.ss.clear();

        for (TableMeta table : schemaList) {
            schemaManager.putTable(table.getTableName(), table);
        }

        logger.warn("table fetched:");
        logger.warn(schemaManager.ss.keySet().toString());
    } catch (Exception e) {
        logger.error("table parser error, schema file is:" + data, e);
        throw new TddlRuntimeException(e);
    } finally {
        IOUtils.closeQuietly(sis);
    }

}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:29,代码来源:StaticSchemaManager.java

示例9: testSimple

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
@Test
public void testSimple() {
    List<TableMeta> tables = TableMetaParser.parse(Thread.currentThread()
        .getContextClassLoader()
        .getResourceAsStream("config/test_table.xml"));
    System.out.println(tables);
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:8,代码来源:TableMetaParserTest.java

示例10: doInit

import com.taobao.tddl.optimizer.config.table.parse.TableMetaParser; //导入依赖的package包/类
protected void doInit() throws TddlException {
    super.doInit();
    ss = new ConcurrentHashMap<String, TableMeta>();

    if (this.appName == null) {
        logger.warn("schema appname is not assigned");
    }

    if (this.schemaFilePath == null) {
        logger.warn("schema file is not assigned");
    }

    if (appName == null && schemaFilePath == null) {
        return;
    }

    ConfigDataHandlerFactory factory = null;
    String dataId = null;

    // 优先从文件获取
    if (schemaFilePath == null) {
        dataId = TDDL5_SCHEMA_DATA_ID.format(new Object[] { appName });
        factory = ConfigDataHandlerCity.getFactory(appName, unitName);
    } else {
        factory = ConfigDataHandlerCity.getFileFactory(appName);
        dataId = schemaFilePath;
    }

    schemaCdh = factory.getConfigDataHandler(dataId, new SchemaConfigDataListener(this));

    String data = schemaCdh.getData(ConfigDataHandler.GET_DATA_TIMEOUT,
        ConfigDataHandler.FIRST_CACHE_THEN_SERVER_STRATEGY);

    if (data == null) {
        schemaCdh.destory();
        // 尝试找一下andor的版本配置
        dataId = ANDOR_SCHEMA_DATA_ID.format(new Object[] { appName });
        schemaCdh = factory.getConfigDataHandler(dataId, new SchemaConfigDataListener(this));
        data = schemaCdh.getData(ConfigDataHandler.GET_DATA_TIMEOUT,
            ConfigDataHandler.FIRST_CACHE_THEN_SERVER_STRATEGY);

    }

    if (data == null) {
        logger.warn(schemaNullError.format(new Object[] { appName, unitName, schemaFilePath, dataId }));
        return;
    }

    InputStream sis = null;
    try {
        sis = new ByteArrayInputStream(data.getBytes());
        List<TableMeta> schemaList = TableMetaParser.parse(sis);

        this.ss.clear();

        for (TableMeta table : schemaList) {
            this.putTable(table.getTableName(), table);
        }

        logger.warn("table fetched:");
        logger.warn(this.ss.keySet().toString());
    } catch (Exception e) {
        logger.error("table parser error, schema file is:\n" + data, e);
        throw new TddlRuntimeException(e);
    } finally {
        IOUtils.closeQuietly(sis);
    }

}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:70,代码来源:StaticSchemaManager.java


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