public Map < Long , Double > zip ( Map < Long , Double > originalDatapoints , Map < Long , Double > baseDatapoints ) { SystemAssert . requireArgument ( baseDatapoints != null && ! baseDatapoints . isEmpty ( ) , "Zipper transform requires valid baseDatapoints from base metric!" ) ; Map < Long , Double > zippedDP = new HashMap <> ( ) ; for ( Map . Entry < Long , Double > originalDP : originalDatapoints . entrySet ( ) ) { Long originalKey = originalDP . getKey ( ) ; Double originalVal = originalDP . getValue ( ) ; // if base datapoints doesn't have the key, give it null Double baseVal = baseDatapoints . containsKey ( originalKey ) ? baseDatapoints . get ( originalKey ) : null ; zippedDP . put ( originalKey , this . valueZipper . zip ( originalVal , baseVal ) ) ; } // if a point exists in the baseDP but does not exist in the original set, // then only add it to the result when fullJoinIndicator is true. if ( fulljoinIndicator ) { for ( Map . Entry < Long , Double > baseDP : baseDatapoints . entrySet ( ) ) { Long baseDPKey = baseDP . getKey ( ) ; if ( ! zippedDP . containsKey ( baseDPKey ) ) { zippedDP . put ( baseDPKey , this . valueZipper . zip ( null , baseDP . getValue ( ) ) ) ; } } } return zippedDP ; }
Merges data points .