@Override public Map<Long,String> mapping(Map<Long,String> originalDatapoints,List<String> constants){
  SystemAssert.requireArgument(constants != null,"This transform needs constants");
  SystemAssert.requireArgument(constants.size() == 2,"This transform must provide exactly 2 constants.");
  this.threshold=getOffsetInSeconds(constants.get(0)) * 1000;
  this.connectDistance=getOffsetInSeconds(constants.get(1)) * 1000;
  Map<Long,String> resultMetric=new TreeMap<Long,String>();
  this.keyList=new ArrayList<Long>();
  this.resultKeyList=new ArrayList<Long>();
  keyList.addAll(originalDatapoints.keySet());
  Collections.sort(keyList);
  if (keyList.size() > 0) {
    connect(0,new ArrayList<>(Arrays.asList(keyList.get(0))));
  }
  for (  Long resultKey : resultKeyList) {
    resultMetric.put(resultKey,originalDatapoints.get(resultKey));
  }
  return resultMetric;
}

@ Override public Map < Long , String > mapping ( Map < Long , String > originalDatapoints , List < String > constants ) { SystemAssert . requireArgument ( constants != null , "This transform needs constants" ) ; SystemAssert . requireArgument ( constants . size ( ) == 2 , "This transform must provide exactly 2 constants." ) ; this . threshold = getOffsetInSeconds ( constants . get ( 0 ) ) * 1000 ; this . connectDistance = getOffsetInSeconds ( constants . get ( 1 ) ) * 1000 ; Map < Long , String > resultMetric = new TreeMap < Long , String > ( ) ; this . keyList = new ArrayList < Long > ( ) ; this . resultKeyList = new ArrayList < Long > ( ) ; keyList . addAll ( originalDatapoints . keySet ( ) ) ; Collections . sort ( keyList ) ; if ( keyList . size ( ) > 0 ) { connect ( 0 , new ArrayList < > ( Arrays . asList ( keyList . get ( 0 ) ) ) ) ; } for ( Long resultKey : resultKeyList ) { resultMetric . put ( resultKey , originalDatapoints . get ( resultKey ) ) ; } return resultMetric ; }
mapping method implementation < br > this is the start point of this transform . it firstly verifies if all inputs are legal , then it crawls forward on this series and collects every qualified adjacent datapoints along the way .
