コード例 #1
0
 @Override
 public void processElement(ProcessContext c) {
   String row =
       c.element().getKey() + " - " + c.element().getValue() + " @ " + c.timestamp().toString();
   System.out.println(row);
   c.output(row);
 }
コード例 #2
0
    @Override
    public void processElement(ProcessContext c) {
      if (c.element().trim().isEmpty()) {
        emptyLines.addValue(1L);
      }

      // Split the line into words.
      String[] words = c.element().split("[^a-zA-Z']+");

      // Output each word encountered into the output PCollection.
      for (String word : words) {
        if (!word.isEmpty()) {
          c.output(word);
        }
      }
    }