private PartitionedEvent constructPE() {
   StreamEvent e = new StreamEvent();
   e.setStreamId("testStreamId");
   e.setTimestamp(1463159382000L);
   e.setData(data);
   StreamPartition sp = new StreamPartition();
   List<String> col = new ArrayList<>();
   col.add("host");
   sp.setColumns(col);
   StreamSortSpec sortSpec = new StreamSortSpec();
   sortSpec.setWindowMargin(30000);
   sortSpec.setWindowPeriod("PT1M");
   sp.setSortSpec(sortSpec);
   sp.setStreamId("testStreamId");
   sp.setType(StreamPartition.Type.GROUPBY);
   PartitionedEvent pe = new PartitionedEvent();
   pe.setEvent(e);
   pe.setPartition(sp);
   pe.setPartitionKey(1000);
   return pe;
 }
 @Override
 public List<StreamEvent> map(Tuple tuple) throws Exception {
   long timestamp;
   if (tuple.getFields().contains(TIMESTAMP_FIELD)) {
     try {
       timestamp = tuple.getLongByField("timestamp");
     } catch (Exception ex) {
       // if timestamp is not null
       LOGGER.error(ex.getMessage(), ex);
       timestamp = 0;
     }
   } else {
     timestamp = System.currentTimeMillis();
   }
   Object[] values = new Object[tuple.getFields().size()];
   for (int i = 0; i < tuple.getFields().size(); i++) {
     values[i] = tuple.getValue(i);
   }
   StreamEvent event = new StreamEvent();
   event.setTimestamp(timestamp);
   event.setStreamId(streamId);
   event.setData(values);
   return Collections.singletonList(event);
 }