public static EpochTransitionRecord computeEpochTransition ( EpochRecord currentEpoch , List < Long > segmentsToSeal , List < Map . Entry < Double , Double > > newRanges , long scaleTimestamp ) { Preconditions . checkState ( segmentsToSeal . stream ( ) . allMatch ( currentEpoch :: containsSegment ) , "Invalid epoch transition request" ) ; int newEpoch = currentEpoch . getEpoch ( ) + 1 ; int nextSegmentNumber = currentEpoch . getSegments ( ) . stream ( ) . mapToInt ( StreamSegmentRecord :: getSegmentNumber ) . max ( ) . getAsInt ( ) + 1 ; ImmutableMap . Builder < Long , Map . Entry < Double , Double > > newSegments = ImmutableMap . builder ( ) ; for ( int i = 0 ; i < newRanges . size ( ) ; i ++ ) { newSegments . put ( computeSegmentId ( nextSegmentNumber + i , newEpoch ) , newRanges . get ( i ) ) ; } return new EpochTransitionRecord ( currentEpoch . getEpoch ( ) , scaleTimestamp , ImmutableSet . copyOf ( segmentsToSeal ) , newSegments . build ( ) ) ; }
Method to compute epoch transition record . It takes segments to seal and new ranges and all the tables and computes the next epoch transition record .