def MapDecoder(field_descriptor, new_default, is_message_map):
key = field_descriptor<EOL>tag_bytes = encoder.TagBytes(field_descriptor.number,<EOL>wire_format.WIRETYPE_LENGTH_DELIMITED)<EOL>tag_len = len(tag_bytes)<EOL>local_DecodeVarint = _DecodeVarint<EOL>message_type = field_descriptor.message_type<EOL>def DecodeMap(buffer, pos, end, message, field_dict):<EOL><INDENT>submsg = message_type._concrete_class()<EOL>value = field_dict.get(key)<EOL>if value is None:<EOL><INDENT>value = field_dict.setdefault(key, new_default(message))<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>(size, pos) = local_DecodeVarint(buffer, pos)<EOL>new_pos = pos + size<EOL>if new_pos > end:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>submsg.Clear()<EOL>if submsg._InternalParse(buffer, pos, new_pos) != new_pos:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>if is_message_map:<EOL><INDENT>value[submsg.key].MergeFrom(submsg.value)<EOL><DEDENT>else:<EOL><INDENT>value[submsg.key] = submsg.value<EOL><DEDENT>pos = new_pos + tag_len<EOL>if buffer[new_pos:pos] != tag_bytes or new_pos == end:<EOL><INDENT>return new_pos<EOL><DEDENT><DEDENT><DEDENT>return DecodeMap<EOL>
Returns a decoder for a map field.