private Segment findSegmentToRelease ( ) { Set < Segment > segments = sync . getState ( ) . getSegments ( readerId ) ; return segments . stream ( ) . max ( ( s1 , s2 ) -> Double . compare ( hashHelper . hashToRange ( s1 . getScopedName ( ) ) , hashHelper . hashToRange ( s2 . getScopedName ( ) ) ) ) . orElse ( null ) ; }
Given a set of segments returns one to release . The one returned is arbitrary .