def _encode_map(dict_obj): kv_list = [(key.encode('utf-8'), val.encode('utf-8')) for key, val in dict_obj.items()] coder = IterableCoder( TupleCoder( [LengthPrefixCoder(BytesCoder()), LengthPrefixCoder(BytesCoder())])) coder_urns = [ 'beam:coder:iterable:v1', 'beam:coder:kv:v1', 'beam:coder:bytes:v1', 'beam:coder:bytes:v1' ] return ConfigValue(coder_urn=coder_urns, payload=coder.encode(kv_list))
def _encode_list(list_obj): encoded_list = [val.encode('utf-8') for val in list_obj] coder = IterableCoder(LengthPrefixCoder(BytesCoder())) coder_urns = ['beam:coder:iterable:v1', 'beam:coder:bytes:v1'] return ConfigValue(coder_urn=coder_urns, payload=coder.encode(encoded_list))