#NEWLINE# def _parse_indented_counters( lines ) : #NEWLINE# #INDENT# 'Parse counters in the indented format output/logged by the\n    Hadoop binary.\n\n    Takes input as lines (should not include log record stuff) and\n    returns a map from counter group to counter to amount.\n    ' #NEWLINE# counters = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# group = None #NEWLINE# group_indent = None #NEWLINE# for line in lines : #NEWLINE# #INDENT# if ( not ( ( group is None ) or ( group_indent is None ) ) ) : #NEWLINE# #INDENT# m = _INDENTED_COUNTER_RE . match ( line ) #NEWLINE# if ( m and ( len ( m . group ( 'indent' ) ) > group_indent ) ) : #NEWLINE# #INDENT# counter = m . group ( 'counter' ) #NEWLINE# amount = int ( m . group ( 'amount' ) ) #NEWLINE# counters . setdefault ( group , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# counters [ group ] [ counter ] = amount #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# m = _INDENTED_COUNTER_GROUP_RE . match ( line ) #NEWLINE# if m : #NEWLINE# #INDENT# group = m . group ( 'group' ) #NEWLINE# group_indent = len ( m . group ( 'indent' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not _INDENTED_COUNTERS_MESSAGE_RE . match ( line ) ) : #NEWLINE# #INDENT# log . warning ( ( 'unexpected counter line: %s' % line ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return counters