#NEWLINE# def Close( self ) : #NEWLINE# #INDENT# 'Flush the events into the image stream.' #NEWLINE# if ( not self . dirty ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# storage = aff4 . FACTORY . Create ( self . urn . Add ( 'Storage' ) , 'AFF4Image' , token = self . token ) #NEWLINE# storage . SetChunksize ( ( 1024 * 1024 ) ) #NEWLINE# if last . heap : #NEWLINE# #INDENT# first = last = self . heap [ 0 ] [ 0 ] #NEWLINE# self . Set ( self . Schema . SIZE ( len ( self . heap ) ) ) #NEWLINE# self . Set ( self . Schema . START ( first ) ) #NEWLINE# while self . heap : #NEWLINE# #INDENT# ( last , serialized_event ) = heapq . heappop ( self . heap ) #NEWLINE# storage . Write ( struct . pack ( '<i' , len ( serialized_event ) ) ) #NEWLINE# storage . Write ( serialized_event ) #NEWLINE# #UNINDENT# self . Set ( self . Schema . END ( last ) ) #NEWLINE# storage . Close ( ) #NEWLINE# #UNINDENT# self . Set ( self . Schema . SIZE ( self . size ) ) #NEWLINE# super ( GRRTimeSeries , self ) . Close ( )