Package com.alibaba.wasp.meta

Examples of com.alibaba.wasp.meta.Index


      MetaException {
    FTable table = FMetaTestUtil.getTestTable();
    List<String> fields = new ArrayList<String>();
    fields.add("c4");
    fields.add("c5");
    Index i1 = FMetaTestUtil.makeIndex(table, "i1", fields);
    table.addIndex(i1);
    fields = new ArrayList<String>();
    fields.add("c5");
    fields.add("c4");
    Index i2 = FMetaTestUtil.makeIndex(table, "i2", fields);
    table.addIndex(i2);

    String sql1 = "SELECT c1, c2, c3 from test where c4=1 and c5=2;";
    String sql2 = "SELECT c1, c2, c3 from test where c5=2 and c4=1;";

    String[] sqlList = { sql1, sql2 }; // sql1, sql2, sql3

    Index[] indexs = { i1, i2 }; // sql1, sql2, sql3

    DruidDQLParser druidParser = new DruidDQLParser(conf);
    for (int i = 0; i < sqlList.length; i++) {
      String sql = sqlList[i];
      context.setSql(sql);
      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
          SQLSelect select = sqlSelectStatement.getSelect();
          SQLSelectQuery sqlSelectQuery = select.getQuery();
          if (sqlSelectQuery instanceof SQLSelectQueryBlock) {
            SQLSelectQueryBlock sqlSelectQueryBlock = (SQLSelectQueryBlock) sqlSelectQuery;
            // Parse The WHERE clause
            SQLExpr where = sqlSelectQueryBlock.getWhere();
            LOG.debug("SELECT SQL:where " + where);
            QueryInfo queryInfo = druidParser.parseWhereClause(table,
                metaEventOperation, where, false);
            Index index = metaEventOperation.checkAndGetIndex(table,
                queryInfo.getAllConditionFieldName());
            // Get the right Index
            Assert.assertEquals(indexs[i].getIndexName(), index.getIndexName());
          }
        }
        Assert.assertTrue(true);
      } catch (IOException ioe) {
        LOG.error(ioe);
View Full Code Here


                  RequestConverter.buildCreateTableRequest(
                      createTable.getTable(), createTable.getSplitKeys()));
          return ResponseConverter.buildExecuteResponse(response);
        } else if (executePlan instanceof CreateIndexPlan) {
          CreateIndexPlan createIndexPlan = (CreateIndexPlan) executePlan;
          Index index = createIndexPlan.getIndex();
          MasterAdminProtos.CreateIndexRequest request = RequestConverter
              .buildCreateIndexRequest(index);
          return ResponseConverter
              .buildExecuteResponse(masterAdminKeepAliveConnection.createIndex(
                  null, request));
View Full Code Here

    // 4. clean Index table in HBase
    LinkedHashMap<String, Index> indexs = ftable.getIndex();
    Iterator<Index> iter = indexs.values().iterator();
    while (iter.hasNext()) {
      Index index = iter.next();
      String htable = StorageTableNameBuilder.buildIndexTableName(index);
      HTableDescriptor htableDesc = fmetaServices.getStorageTableDesc(htable);
      fmetaServices.deleteStorageTable(htable);
      fmetaServices.createStorageTable(htableDesc);
    }
View Full Code Here

TOP

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

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.