Package com.alibaba.wasp.meta

Examples of com.alibaba.wasp.meta.Index


      }
      qp = new LocalQueryPlan((GetAction) action);
      LOG.debug(QueryInfo.QueryType.GET + "  "
          + Bytes.toStringBinary(primaryKey) + " from " + table.getTableName());
    } else if (queryInfo.getType() == QueryInfo.QueryType.SCAN) {
      Index index = metaEventOperation.checkAndGetIndex(table,
          queryInfo.getAllConditionFieldName());

      if (index == null) {
        throw new UnsupportedException("Don't get a Index!");
      }

      boolean isJustUseIndex = index.getIndexKeys().size() >= queryInfo.getAllConditionFieldName().size();
      Pair<byte[], byte[]> startKeyAndEndKey = metaEventOperation.getStartkeyAndEndkey(index, queryInfo);

      Pair<List<ColumnStruct>, List<ColumnStruct>> columnActionPair = this
          .buildEntityColumnsForScan(table, index, metaEventOperation,
              selectItem);
View Full Code Here


    LinkedHashMap<String, Field> indexKeys = metaEventOperation
        .checkAndGetFields(fTable, columns);
    // Check the indexKeys whether have Duplicate column name
    metaEventOperation.areLegalTableColumns(null, indexKeys.values());

    Index index = new Index(indexName, tableName, indexKeys);
    // Check if two index have the same columns and the same columns order
    metaEventOperation.checkTwoIndexWithSameColumn(fTable, index);

    index.setDesc(desc);
    index.setStoring(parse(sqlCreateIndexStatement.getStoringCols(),
        fTable.getColumns()));
    CreateIndexPlan createIndexPlan = new CreateIndexPlan(index);

    context.setPlan(createIndexPlan);
    LOG.debug("CreateIndexPlan " + createIndexPlan.toString());
View Full Code Here

  public void checkIsPrimaryKeyOrIndex(FTable table, List<String> columns)
      throws IOException {
    if (arePrimaryKeys(table, columns)) {
      return;
    } else {
      Index index = checkAndGetIndex(table, columns);
      if (index == null) {
        throw new UnsupportedException("Not a PrimaryKey or a Index");
      }
    }
  }
View Full Code Here

  public static FTable convertITableSchema(MasterMonitorProtos.ITableSchema proto) {
    FTable table = FTable.convert(proto.getTableSchema());
    LinkedHashMap<String, Index> indexs = new LinkedHashMap<String, Index>();
    for (MetaProtos.IndexSchema indexSchema : proto.getIndexSchemaList()) {
      Index index = Index.convert(indexSchema);
      indexs.put(index.getIndexName(), index);
    }
    table.setIndex(indexs);
    return table;
  }
View Full Code Here

   *      com.alibaba.wasp.protobuf.generated.MasterAdminProtos.CreateIndexRequest)
   */
  @Override
  public CreateIndexResponse createIndex(RpcController controller,
      CreateIndexRequest request) throws ServiceException {
    Index index = Index.convert(request.getIndexSchema());
    try {
      checkInitialized();
      CreateIndexHandler ciHandle = new CreateIndexHandler(Bytes.toBytes(index
          .getDependentTableName()), index, this, this,
          EventHandler.EventType.C_M_CREATE_INDEX);
      this.executorService.submit(ciHandle);
    } catch (IOException ioe) {
      throw new ServiceException(ioe);
View Full Code Here

  public String describeIndex(String tableName, String indexName)
      throws IOException {
    FTable table = getTableDescriptor(Bytes.toBytes(tableName));
    LinkedHashMap<String, Index> indexMap = table.getIndex();
    Index index = indexMap.get(indexName);
    if (index == null) {
      return "";
    }

    StringBuilder builder = new StringBuilder();
    builder.append("+----------------------+----------+-------+\n");
    builder.append("|              INDEX_KEYS                 |\n");
    builder.append("+----------------------+----------+-------+\n");
    builder.append("| Field                | Type     | ORDER |\n");
    builder.append("+----------------------+----------+-------+\n");
    String line = "| {0} | {1} | {2} |";
    LinkedHashMap<String, Field> indexKeys = index.getIndexKeys();
    Map<String, Field> storings = index.getStoring();
    Set<String> desc = index.getDesc();

    for (Field field : indexKeys.values()) {
      String fieldname = field.getName();
      String s0 = fieldname
          + (fieldname.length() < 20 ? getGivenBlanks(20 - fieldname.length())
View Full Code Here

      Assert.assertTrue(result);
      try {
        Plan plan = context.getPlan();
        if (plan instanceof CreateIndexPlan) {
          CreateIndexPlan createIndex = (CreateIndexPlan) plan;
          Index index = createIndex.getIndex();
          TableSchemaCacheReader.getService(conf).addIndex(
              index.getDependentTableName(), index);
        } else {
          Assert.assertTrue(false);
        }
      } catch (IOException ioe) {
        ioe.printStackTrace();
View Full Code Here

      Assert.assertTrue(result);
      try {
        Plan plan = context.getPlan();
        if (plan instanceof CreateIndexPlan) {
          CreateIndexPlan createIndex = (CreateIndexPlan) plan;
          Index index = createIndex.getIndex();
          TableSchemaCacheReader.getService(conf).addIndex(
              index.getDependentTableName(), index);
        } else if (plan instanceof DropIndexPlan) {
          DropIndexPlan dropIndex = (DropIndexPlan) plan;
          String tableName = dropIndex.getTableName();
          String indexName = dropIndex.getIndexName();
          Index index = TableSchemaCacheReader.getService(conf).getIndex(
              tableName, indexName);
          TableSchemaCacheReader.getService(conf).deleteIndex(
              index.getDependentTableName(), index);
        } else {
          Assert.assertTrue(false);
        }
        Assert.assertTrue(true);
      } catch (IOException ioe) {
View Full Code Here

      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

          TableSchemaCacheReader.getService(conf).createTable(ftable);
          TableSchemaCacheReader.getInstance(conf).addSchema(
              ftable.getTableName(), ftable);
        } else if (plan instanceof CreateIndexPlan) {
          CreateIndexPlan createIndex = (CreateIndexPlan) plan;
          Index index = createIndex.getIndex();
          TableSchemaCacheReader.getService(conf).addIndex(
              index.getDependentTableName(), index);
          TableSchemaCacheReader.getInstance(conf).refreshSchema(
              index.getDependentTableName());
        } else {
        }
      } catch (IOException ioe) {
        // ioe.printStackTrace();
        LOG.error(ioe);
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.