private TimeSeriesValue interpolateTSV ( GroupName name ) { final Map . Entry < DateTime , TimeSeriesValue > backTSV = findName ( backward , name ) , forwTSV = findName ( forward , name ) ; final long backMillis = max ( new Duration ( backTSV . getKey ( ) , getTimestamp ( ) ) . getMillis ( ) , 0 ) , forwMillis = max ( new Duration ( getTimestamp ( ) , forwTSV . getKey ( ) ) . getMillis ( ) , 0 ) ; final double totalMillis = forwMillis + backMillis ; final double backWeight = forwMillis / totalMillis ; final double forwWeight = backMillis / totalMillis ; return new InterpolatedTSV ( name , backTSV . getValue ( ) . getMetrics ( ) , forwTSV . getValue ( ) . getMetrics ( ) , backWeight , forwWeight ) ; }
Interpolates a group name based on the most recent backward and oldest forward occurence .