【发布时间】:2017-10-10 22:24:57
【问题描述】:
如果我在 GCS 上存储了一个 .txt 文件,其中包含将用作 beam.Filter 一部分的单词列表,是否可以在我的 apache 光束管道中动态访问此列表?我知道我可以将此列表定义为管道中的全局变量,但我不确定如何将整个文件读入列表以及是否有任何光束技巧来完成此操作。有什么建议么?这是我当前的实现,它不起作用..
def boolean_terms(word, term_list):
if word in term_list:
return (word, 1)
else:
return (word, 0)
# side table
filter_terms = p | beam.io.ReadFromText(path_to_gcs_txt_file)
words = ...
filtered_words = words | beam.FlatMap(lambda x:
[boolean_terms(word, filter_terms) for word in x])
我收到以下错误“TypeError:'_InvalidUnpickledPCollection' 类型的参数不可迭代”
【问题讨论】:
标签: python google-cloud-dataflow apache-beam