Package com.alibaba.wasp.meta

Examples of com.alibaba.wasp.meta.TableSchemaCacheReader


    transactionAction.setEntityGroupLocation(entityGroupLocation);
    return transactionAction;
  }

  private static String checkTablesAndGetParent(Set<String> checkTables, ParseContext context) throws MetaException, TransactionParseException {
    TableSchemaCacheReader reader = context.getTsr();
    String parentTable = null;
    for (String checkTable : checkTables) {
      FTable table = reader.getSchema(checkTable);
      if(table.getTableType() == FTable.TableType.ROOT) {
        if(parentTable != null && !parentTable.equals(table.getTableName())) {
          throw new TransactionParseException("in a transaction can be no more than one parent table");
        } else {
          parentTable = table.getTableName();
View Full Code Here


            + " != references table "
            + waspSqlCreateTableStatement.getReferenceTable());
      }

      // Check parent's EGK equals child's EGK.
      TableSchemaCacheReader reader = TableSchemaCacheReader
          .getInstance(configuration);
      FTable parentTable = reader.getSchema(parentName);
      if (parentTable == null) {
        parentTable = TableSchemaCacheReader.getService(reader.getConf())
            .getTable(tableName);
      }
      if (parentTable == null) {
        throw new TableNotFoundException("Not found parent table:" + parentName);
      }
View Full Code Here

    DruidDQLParser dqlParser = new DruidDQLParser(conf, null);
    DruidDDLParser ddlParser = new DruidDDLParser(conf);
    DruidDMLParser dmlParser = new DruidDMLParser(conf, null);
    druidParser = new WaspParser(ddlParser, dqlParser, dmlParser);
    MemFMetaStore fmetaServices = new MemFMetaStore();
    TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf,
        fmetaServices);
    reader.clearCache();
    context.setTsr(reader);
    // create table
    String createTable = DruidParserTestUtil.SEED[0];
    context.setSql(createTable);
    druidParser.generatePlan(context);
    Plan plan = context.getPlan();
    if (plan instanceof CreateTablePlan) {
      CreateTablePlan createPlan = (CreateTablePlan) plan;
      table = createPlan.getTable();
      TableSchemaCacheReader.getService(conf).createTable(table);
      reader.addSchema(table.getTableName(), table);
    }
    EntityGroupInfo egi = new EntityGroupInfo(table.getTableName(), null, null);
    MockFServerServices service = new MockFServerServices();
    eg = new EntityGroup(conf, egi, table, service);
    NullStorageServices storageServices = new NullStorageServices();
View Full Code Here

      "CREATE index PhotosByTime on Photo(user_id,time);",
      "CREATE index PhotosByTag on Photo(tag);" };

  public static void loadTable(Configuration conf) throws MetaException, ZooKeeperConnectionException {
    MemFMetaStore fmetaServices = new MemFMetaStore();
    TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf, fmetaServices);
    ParseContext context = new ParseContext();
    context.setTsr(reader);
    DruidDQLParser dqlParser = new DruidDQLParser(conf, null);
    DruidDDLParser ddlParser = new DruidDDLParser(conf);
    DruidDMLParser dmlParser = new DruidDMLParser(conf, null);
View Full Code Here

        Plan plan = context.getPlan();
        if (plan instanceof CreateTablePlan) {
          CreateTablePlan createTable = (CreateTablePlan) plan;
          FTable ftable = createTable.getTable();
          fmetaServices.createTable(ftable);
          TableSchemaCacheReader reader = TableSchemaCacheReader
              .getInstance(fmetaServices.getConf());
          reader.addSchema(ftable.getTableName(), ftable);
        }
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
View Full Code Here

    context.setGenWholePlan(false);
    DruidDQLParser dqlParser = new DruidDQLParser(conf);
    DruidDDLParser ddlParser = new DruidDDLParser(conf);
    DruidDMLParser dmlParser = new DruidDMLParser(conf);
    druidParser = new WaspParser(ddlParser, dqlParser, dmlParser);
    TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf);
    reader.clearCache();
    context.setTsr(reader);
    // create table
    table = new FTable[DruidParserTestUtil.SEED.length];
    for (int i = 0; i < DruidParserTestUtil.SEED.length; i++) {
      String createTable = DruidParserTestUtil.SEED[i];
      context.setSql(createTable);
      druidParser.generatePlan(context);
      Plan plan = context.getPlan();
      if (plan instanceof CreateTablePlan) {
        CreateTablePlan createPlan = (CreateTablePlan) plan;
        table[i] = createPlan.getTable();
        TableSchemaCacheReader.getService(conf).createTable(table[i]);
        reader.addSchema(table[i].getTableName(), table[i]);
      }
    }
    for (int i = 0; i < DruidParserTestUtil.INDEX_SEED.length; i++) {
      String createIndex = DruidParserTestUtil.INDEX_SEED[i];
      context.setSql(createIndex);
      druidParser.generatePlan(context);
      Plan plan = context.getPlan();
      if (plan instanceof CreateIndexPlan) {
        CreateIndexPlan createIndexPlan = (CreateIndexPlan) plan;
        Index index = createIndexPlan.getIndex();
        TableSchemaCacheReader.getService(conf).addIndex(
            index.getDependentTableName(), index);
        reader.refreshSchema(index.getDependentTableName());
      }
    }
    for (FTable ftable : table) {
      TableSchemaCacheReader.getInstance(conf).refreshSchema(
          ftable.getTableName());
View Full Code Here

      try {
        druidParser.parseSqlToStatement(context);
        SQLStatement stmt = context.getStmt();
        if (stmt instanceof SQLSelectStatement) {
          MemFMetaStore fmetaServices = new MemFMetaStore();
          TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(
              conf, fmetaServices);
          reader.addSchema(table.getTableName(), table);
          MetaEventOperation metaEventOperation = new FMetaEventOperation(
              reader);

          SQLSelectStatement sqlSelectStatement = (SQLSelectStatement) stmt;
          // this is SELECT clause
View Full Code Here

  public void testGenerateInsertAction() {
    String createTable = "CREATE TABLE User {Required Int64 user_id; Required String name; } "
        + "primary key(user_id), entity group root, entity group key(user_id);";
    String insert = "Insert into User(user_id,name) values(1,'binlijin');";
    try {
      TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf);
      context.setTsr(reader);

      DruidDQLParser dqlParser = new DruidDQLParser(conf, null);
      DruidDDLParser ddlParser = new DruidDDLParser(conf);
      DruidDMLParser dmlParser = new DruidDMLParser(conf, null);
View Full Code Here

  @Test
  public void testGenerateTransactionAction() {

    try {
      TableSchemaCacheReader reader = TableSchemaCacheReader.getInstance(conf);
      context.setTsr(reader);

      DruidDQLParser dqlParser = new DruidDQLParser(conf, null);
      DruidDDLParser ddlParser = new DruidDDLParser(conf);
      DruidDMLParser dmlParser = new DruidDMLParser(conf, null);
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.meta.TableSchemaCacheReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.