#NEWLINE# def update_node_stats( self ) : #NEWLINE# #INDENT# '\n        Fetches local stats from all shards, aggregates them, and\n        rebroadcasts global stats back to shards.  Currently uses\n        "brute-force"; incremental updating (in either direction)\n        is not supported.\n        ' #NEWLINE# def merge_df_map( target , source ) : #NEWLINE# #INDENT# '\n            Helper function to merge df_maps.\n            ' #NEWLINE# for ( term , df ) in source . items ( ) : #NEWLINE# #INDENT# if ( term not in target ) : #NEWLINE# #INDENT# target [ term ] = 0 #NEWLINE# #UNINDENT# target [ term ] += df #NEWLINE# #UNINDENT# #UNINDENT# self . _N = 0 #NEWLINE# self . _df_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# name_to_docid_maps = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for shard_id in range ( len ( self . _shards ) ) : #NEWLINE# #INDENT# shard = self . _shards [ shard_id ] #NEWLINE# self . _N += shard . get_local_N ( ) #NEWLINE# merge_df_map ( self . _df_map , shard . get_local_df_map ( ) ) #NEWLINE# name_to_docid_maps [ shard_id ] = shard . get_name_to_docid_map ( ) #NEWLINE# #UNINDENT# for ( shard_id , name_to_docid_map ) in name_to_docid_maps . iteritems ( ) : #NEWLINE# #INDENT# for ( name , docid ) in name_to_docid_map . iteritems ( ) : #NEWLINE# #INDENT# gdocid = self . make_node_docid ( shard_id , docid ) #NEWLINE# self . _name_to_docid_map [ name ] = gdocid #NEWLINE# self . _docid_to_name_map [ gdocid ] = name