Ejemplo n.º 1
0
 @Override
 public void execute(Tuple tuple, BasicOutputCollector collector) {
   String word = tuple.getString(0);
   Integer count = counts.get(word);
   if (count == null) count = 0;
   count++;
   counts.put(word, count);
   collector.emit(new Values(word, count));
 }
Ejemplo n.º 2
0
 @Override
 public void execute(Tuple input, BasicOutputCollector collector) {
   String line = input.getString(0);
   String[] fields = line.split(seprator);
   try {
     pstmt = conn.prepareStatement(insertSql);
     for (int i = 0; i < fields.length; i++) {
       pstmt.setString(i + 1, fields[i]);
     }
     pstmt.executeUpdate();
   } catch (SQLException e) {
     log.error("数据插入失败", e);
     throw new RuntimeException("数据插入失败", e);
   }
   collector.emit(new Values(line));
 }
Ejemplo n.º 3
0
 @Override
 public void execute(Tuple input, BasicOutputCollector collector) {
   collector.emit(input.getValues());
 }