コード例 #1
0
  private void setInputStreams(StreamingConfig config) throws ExecutorException {
    String orderedStreams = combineOperator.getOrderedStreams();
    List<String> inputStreamNames = Lists.newArrayList();
    String[] strs = orderedStreams.split(",");
    for (int i = 0; i < strs.length; i++) {
      inputStreamNames.add(getPlanStreamNameFromTransition(strs[i]));
    }

    config.put(StreamingConfig.OPERATOR_COMBINE_INPUTNAMES, inputStreamNames);
  }
コード例 #2
0
  private void setCombineConditions(StreamingConfig config) throws ExecutorException {
    Map<String, String> keyMap = Maps.newHashMap();
    List<ExpressionDescribe> exps =
        createCombineExpressions(combineOperator.getCombineProperties());

    for (ExpressionDescribe exp : exps) {
      PropertyValueExpressionDesc pexp = (PropertyValueExpressionDesc) exp;
      String streamName = pexp.getSchemaId();
      keyMap.put(getPlanStreamNameFromTransition(streamName), pexp.getProperty());
    }
    config.put(StreamingConfig.OPERATOR_COMBINE_INPUTNAMES_AND_KEY, keyMap);
  }
コード例 #3
0
  private void setCombineOutputs(StreamingConfig config) throws ExecutorException {

    List<ExpressionDescribe> exps = createCombineExpressions(combineOperator.getOutputExpression());

    /*
     * 需要检查相同的流属性必须放在一起
     */
    List<String> combineStreams = Lists.newArrayList();
    List<List<PropertyValueExpression>> tmpOuts = Lists.newArrayList();

    for (int i = 0; i < exps.size(); i++) {
      if (!(exps.get(i) instanceof PropertyValueExpressionDesc)) {

        ExecutorException exception =
            new ExecutorException(ErrorCode.SEMANTICANALYZE_COMBINE_SIMPLE_EXPRESSION);
        LOG.error("Not property value expression in combie clause.", exception);

        throw exception;
      }
      PropertyValueExpressionDesc pexp = (PropertyValueExpressionDesc) exps.get(i);
      String streamName = pexp.getSchemaId();
      PropertyValueExpression expression =
          (PropertyValueExpression) new PropertyValueExpressionCreator().createInstance(pexp, null);

      if (combineStreams.size() == 0) {
        combineStreams.add(streamName);
        tmpOuts.add(new ArrayList<PropertyValueExpression>());
        tmpOuts.get(tmpOuts.size() - 1).add(expression);
      } else {
        if (combineStreams.get(combineStreams.size() - 1).equals(streamName)) {
          tmpOuts.get(tmpOuts.size() - 1).add(expression);
        } else {
          /*
           * 如果出现不一样的流名称,先检查该流名称是否已经出现过
           * 如果出现过,就报错,因为combine中的列必须是按照顺序进行的。
           */
          checkStreamNameRepeated(combineStreams, streamName);

          combineStreams.add(streamName);
          tmpOuts.add(new ArrayList<PropertyValueExpression>());
          tmpOuts.get(tmpOuts.size() - 1).add(expression);
        }
      }
    }
    // 查询顺序取决于这个参数
    config.put(
        StreamingConfig.OPERATOR_COMBINE_INPUTNAMES_AND_EXPRESSION,
        createOutputMaps(combineStreams, tmpOuts));
  }