コード例 #1
0
  @Override
  public void endStream() throws Exception {
    if (_metaTuple != null) {
      componentContext.pushDataComponentToOutput(OUT_META_TUPLE, _metaTuple);
      componentContext.pushDataComponentToOutput(OUT_TUPLES, _tuples.build());
    } else console.warning("Nothing to push - the stream did not contain any tuples");

    _tuples = null;
  }
コード例 #2
0
  @Override
  public void executeCallBack(ComponentContext cc) throws Exception {
    if (_tuples == null) throw new ComponentExecutionException("Start stream marker not received!");

    Strings inputMeta = (Strings) cc.getDataComponentFromInput(IN_META_TUPLE);
    Object input = cc.getDataComponentFromInput(IN_TUPLES);
    Strings[] tuples;

    if (input instanceof StringsArray)
      tuples = BasicDataTypesTools.stringsArrayToJavaArray((StringsArray) input);
    else if (input instanceof Strings) tuples = new Strings[] {(Strings) input};
    else
      throw new ComponentExecutionException(
          "Don't know how to handle input of type: " + input.getClass().getName());

    if (_metaTuple != null && !equalMeta(_metaTuple, inputMeta))
      throw new ComponentExecutionException("Tuple metadata mismatch!");

    _metaTuple = inputMeta;

    for (Strings tuple : tuples) _tuples.addValue(tuple);
  }