Package com.alibaba.wasp.plan.action

Examples of com.alibaba.wasp.plan.action.Action


        throw new UnsupportedException(
            "When you have specified the pk, you'd better not to specify additional filter conditions.");
      }
    }

    Action action = null;
    DQLPlan qp = null;

    Condition entityGroupKeyCondition = queryInfo.getField(table
        .getEntityGroupKey().getName());
    if (queryInfo.getType() == QueryInfo.QueryType.GET) {
      byte[] primaryKey = RowBuilder.build().genRowkey(primaryKeyPairs);
      // check if the column is table's primary key.
      action = new GetAction(context.getReadModel(), table.getTableName(),
          primaryKey, this.buildEntityColumnsForGet(table, metaEventOperation,
              selectItem));
      ((GetAction)action).setForUpdate(queryInfo.isForUpdate());
      if (context.isGenWholePlan()) {
        // get entityGroupLocation according to entity group key.
        EntityGroupLocation entityGroupLocation = this.connection
            .locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
                .convert(
                    table.getColumn(entityGroupKeyCondition.getFieldName()),
                    entityGroupKeyCondition.getValue()));
        action.setEntityGroupLocation(entityGroupLocation);
      }
      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);
      List<ColumnStruct> selectEntityColumns = columnActionPair.getFirst();
      List<ColumnStruct> selectStoringColumns = columnActionPair.getSecond();
      List<ColumnStruct> conditionNotInIndex = isJustUseIndex ? Collections.<ColumnStruct>emptyList()
          : buildColumnsNotInIndex(table, index, queryInfo);

      // instance scan action.
      action = new ScanAction(context.getReadModel(),
          StorageTableNameBuilder.buildIndexTableName(index),
          table.getTableName(), startKeyAndEndKey.getFirst(),
          startKeyAndEndKey.getSecond(), selectEntityColumns);
      ((ScanAction) action).setStoringColumns(selectStoringColumns);
      ((ScanAction) action).setLimit(limit);
      ((ScanAction) action).setNotIndexConditionColumns(conditionNotInIndex);

      if (entityGroupKeyCondition != null
          && entityGroupKeyCondition.getType() == ConditionType.EQUAL) {
        if (context.isGenWholePlan()) {
          EntityGroupLocation entityGroupLocation = this.connection
              .locateEntityGroup(Bytes.toBytes(table.getTableName()),
                  DruidParser.convert(
                      table.getColumn(entityGroupKeyCondition.getFieldName()),
                      entityGroupKeyCondition.getValue()));
          action.setEntityGroupLocation(entityGroupLocation);
        }
        qp = new LocalQueryPlan((ScanAction) action);
        LOG.debug(QueryInfo.QueryType.SCAN + " startKey "
            + Bytes.toStringBinary(startKeyAndEndKey.getFirst()) + " endKey "
            + Bytes.toStringBinary(startKeyAndEndKey.getSecond()));
View Full Code Here


    entityGroups.add(entityGroup3);

    List<Action> actions1 = new ArrayList<Action>();
    List<Action> actions2 = new ArrayList<Action>();
    List<Action> actions3 = new ArrayList<Action>();
    Action action1 = new InsertAction("testtable1", Bytes.toBytes("PK1"));
    Action action2 = new InsertAction("testtable2", Bytes.toBytes("PK2"));
    Action action3 = new InsertAction("testtable3", Bytes.toBytes("PK3"));
    actions1.add(action1);
    actions2.add(action2);
    actions3.add(action3);

    Map<EntityGroupInfo, List<Action>> transcation = new HashMap<EntityGroupInfo, List<Action>>();
View Full Code Here

   * @return
   * @throws com.google.protobuf.InvalidProtocolBufferException
   */
  public static byte[] toMessage(Message message)
      throws InvalidProtocolBufferException {
    Action action = (Action) message;
    MessageProto proto = ProtobufUtil.convertWriteAction(action);
    return proto.toByteArray();
  }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.plan.action.Action

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.