public void update ( final ArrayOfDoublesSketch sketchIn , final ArrayOfDoublesCombiner combiner ) { final boolean isFirstCall = isFirstCall_ ; isFirstCall_ = false ; if ( sketchIn == null ) { isEmpty_ = true ; sketch_ = null ; return ; } Util . checkSeedHashes ( seedHash_ , sketchIn . getSeedHash ( ) ) ; theta_ = min ( theta_ , sketchIn . getThetaLong ( ) ) ; isEmpty_ |= sketchIn . isEmpty ( ) ; if ( isEmpty_ || sketchIn . getRetainedEntries ( ) == 0 ) { sketch_ = null ; return ; } if ( isFirstCall ) { sketch_ = createSketch ( sketchIn . getRetainedEntries ( ) , numValues_ , seed_ ) ; final ArrayOfDoublesSketchIterator it = sketchIn . iterator ( ) ; while ( it . next ( ) ) { sketch_ . insert ( it . getKey ( ) , it . getValues ( ) ) ; } } else { //not the first call final int matchSize = min ( sketch_ . getRetainedEntries ( ) , sketchIn . getRetainedEntries ( ) ) ; final long [ ] matchKeys = new long [ matchSize ] ; final double [ ] [ ] matchValues = new double [ matchSize ] [ ] ; int matchCount = 0 ; final ArrayOfDoublesSketchIterator it = sketchIn . iterator ( ) ; while ( it . next ( ) ) { final double [ ] values = sketch_ . find ( it . getKey ( ) ) ; if ( values != null ) { matchKeys [ matchCount ] = it . getKey ( ) ; matchValues [ matchCount ] = combiner . combine ( values , it . getValues ( ) ) ; matchCount ++ ; } } sketch_ = null ; if ( matchCount > 0 ) { sketch_ = createSketch ( matchCount , numValues_ , seed_ ) ; for ( int i = 0 ; i < matchCount ; i ++ ) { sketch_ . insert ( matchKeys [ i ] , matchValues [ i ] ) ; } } if ( sketch_ != null ) { sketch_ . setThetaLong ( theta_ ) ; sketch_ . setNotEmpty ( ) ; } } }
Updates the internal set by intersecting it with the given sketch .