Package com.alibaba.wasp.plan

Examples of com.alibaba.wasp.plan.LocalQueryPlan


                .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()));
      } else {
        qp = new GlobalQueryPlan((ScanAction) action, table);
View Full Code Here


        context.setSql(select[i]);
        druidParser.generatePlan(context);
        plan = context.getPlan();
        LOG.info("Plan is " + plan.toString());
        if (plan instanceof LocalQueryPlan) {
          LocalQueryPlan localQueryPlan = (LocalQueryPlan) plan;
          GetAction getAction = localQueryPlan.getGetAction();
          if (getAction != null) {
            LOG.info("GetAction " + getAction.toString());
            Result rs = eg.get(getAction);
            LOG.info("Result " + rs.toString());
            if (!rs.isEmpty()) {
              Collection<Field> columns = testFTable[i].getColumns().values();
              for (Field f : columns) {
                try {
                  byte[] value = rs.getValue(Bytes.toBytes(f.getFamily()),
                      Bytes.toBytes(f.getName()));
                  if (f.getType() == DataType.INT64) {
                    LOG.info("Column:" + f.getName() + " , value:"
                        + Bytes.toLong(value));
                  } else if (f.getType() == DataType.STRING) {
                    LOG.info("Column:" + f.getName() + " , value:"
                        + Bytes.toString(value));
                  } else if (f.getType() == DataType.INT32) {
                    LOG.info("Column:" + f.getName() + " , value:"
                        + Bytes.toInt(value));
                  } else if (f.getType() == DataType.DOUBLE) {
                    LOG.info("Column:" + f.getName() + " , value:"
                        + Bytes.toDouble(value));
                  } else if (f.getType() == DataType.FLOAT) {
                    LOG.info("Column:" + f.getName() + " , value:"
                        + Bytes.toFloat(value));
                  }
                } catch (Throwable e) {
                  LOG.error("Why?(" + f.getFamily() + ":" + f.getName() + ")",
                      e);
                  throw e;
                }
              }
            }
          } else {
            ScanAction scanAction = localQueryPlan.getScanAction();
            executeScanAction(eg, scanAction, testFTable[i]);
          }
        } else {
          GlobalQueryPlan globalQueryPlan = (GlobalQueryPlan) plan;
          ScanAction scanAction = globalQueryPlan.getAction();
View Full Code Here

        .getConfiguration()));
    context.setSql(sql);
    context.setReadModel(ReadModel.CURRENT);
    parser.generatePlan(context);

    LocalQueryPlan plan = (LocalQueryPlan) context.getPlan();

    Pair<Boolean, Pair<String, Pair<List<QueryResultProto>, List<StringDataTypePair>>>> rets = engine
        .execQueryPlan(plan, "", false);
    if (!exits) {
      assertTrue(rets.getSecond().getSecond().getFirst().size() == 0);
View Full Code Here

        }
      } else {
        session = addSession();
        sessionName = session.getSessionId();
        if (plan instanceof LocalQueryPlan) {
          LocalQueryPlan localQueryPlan = (LocalQueryPlan) plan;
          if (localQueryPlan.getScanAction() != null) {
            session.setExecutor(new LocalScanExecutor(localQueryPlan));
          } else if (localQueryPlan.getGetAction() != null) {
            localQueryPlan.getGetAction().setSessionId(sessionName);
            session.setExecutor(new LocalGetExecutor(localQueryPlan));
          }
        } else if (plan instanceof GlobalQueryPlan) {
          session.setExecutor(new GlobalQueryExecutor((GlobalQueryPlan) plan,
              server));
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.plan.LocalQueryPlan

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.