我想知道为什么这个#sideInput()方法移到了ProcessContext课堂?以前我可以在#startBundle()方法中做一些额外的处理并缓存结果.这样做#processElement()听起来效率低下.当然,我可以在将数据传递给视图之前进行预处理,但是仍然需要调用#sideInput()每个元素的开销......
谢谢,G
我正在尝试使用AvroCoder序列化自定义类型,该类型在我的管道中的PCollections中传递.自定义类型有一个通用字段(当前是一个字符串)当我运行管道时,我得到如下的AvroTypeException可能是由于泛型字段.为这个对象构建和传递AvroSchema是解决这个问题的唯一方法吗?
Exception in thread "main" org.apache.avro.AvroTypeException: Unknown type: T
at org.apache.avro.specific.SpecificData.createSchema(SpecificData.java:255)
at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:514)
at org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:593)
at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:472)
at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:189)
at com.google.cloud.dataflow.sdk.coders.AvroCoder.of(AvroCoder.java:116)
Run Code Online (Sandbox Code Playgroud)
我还附上了我的注册表代码以供参考.
pipelineCoderRegistry.registerCoder(GenericTypeClass.class, new CoderFactory() {
@Override
public Coder<?> create(List<? extends Coder<?>> componentCoders) {
return AvroCoder.of(GenericTypeClass.class);
}
@Override
public List<Object> getInstanceComponents(Object value) {
return Collections.singletonList(((GenericTypeClass<Object>) value).key);
}
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置我的开发环境.我一直在使用pubsub模拟器进行开发和测试,而不是在生产中使用google cloud pubsub.为此,我设置了以下环境变量:
export PUBSUB_EMULATOR_HOST=localhost:8586
Run Code Online (Sandbox Code Playgroud)
这适用于python google pubsub库但是当我切换到使用java apache beam for google dataflow时,管道仍指向生产google pubsub.管道上是否有设置,环境变量或方法需要设置,以便管道读取本地pubsub模拟器?
据我所知,将数据流式传输到BigQuery会导致重复的行,因为它在这里提到https://cloud.google.com/bigquery/streaming-data-into-bigquery#real-time_dashboards_and_queries
另一方面,将数据上传到PubSub,然后使用数据流将数据插入Bigquery将阻止重复的行?此处还有一个实时数据分析教程https://cloud.google.com/solutions/real-time/fluentd-bigquery
那么还有什么其他优点和缺点,在什么情况下我应该使用数据流从PubSub传输数据
我们从Google Dataflow 1.9迁移到Apache Beam 0.6.应用globalwindow后,我们注意到行为更改为时间戳.在Google Dataflow 1.9中,我们会在窗口化/合并功能后在DoFn中获得正确的时间戳.现在我们为时间戳获得了一些巨大的价值,例如9223371950454775,全局窗口的默认行为是否在Apache Beam版本中发生了变化?
input.apply(name(id, "Assign To Shard"), ParDo.of(new AssignToTest()))
.apply(name(id, "Window"), Window
.<KV<Long, ObjectNode >>into(new GlobalWindows())
.triggering(Repeatedly.forever(
AfterProcessingTime
.pastFirstElementInPane()
.plusDelayOf(Duration.standardMinutes(1))))
.discardingFiredPanes())
.apply(name(id, "Group By Shard"), GroupByKey.create())
.appy(.....) }
Run Code Online (Sandbox Code Playgroud) 我想从两个不同的JSON文件中找出女性员工,只选择我们感兴趣的字段并将输出写入另一个JSON.
此外,我正在尝试使用Dataflow在Google的云平台上实现它.有人可以提供任何可以实现的示例Java代码来获得结果.
员工JSON
{"emp_id":"OrgEmp#1","emp_name":"Adam","emp_dept":"OrgDept#1","emp_country":"USA","emp_gender":"female","emp_birth_year":"1980","emp_salary":"$100000"}
{"emp_id":"OrgEmp#1","emp_name":"Scott","emp_dept":"OrgDept#3","emp_country":"USA","emp_gender":"male","emp_birth_year":"1985","emp_salary":"$105000"}
Run Code Online (Sandbox Code Playgroud)
部门JSON
{"dept_id":"OrgDept#1","dept_name":"Account","dept_start_year":"1950"}
{"dept_id":"OrgDept#2","dept_name":"IT","dept_start_year":"1990"}
{"dept_id":"OrgDept#3","dept_name":"HR","dept_start_year":"1950"}
Run Code Online (Sandbox Code Playgroud)
预期的输出JSON文件应该是这样的
{"emp_id":"OrgEmp#1","emp_name":"Adam","dept_name":"Account","emp_salary":"$100000"}
Run Code Online (Sandbox Code Playgroud) 我需要从GCS存储桶中读取文件.我知道我将不得不使用GCS API /客户端库,但我找不到任何与之相关的示例.
我一直在参考GCS文档中的这个链接: GCS客户端库.但真的不能成功.如果有人能提供一个真正有用的例子.谢谢.
在分布式处理环境中,通常使用"部分"文件名,例如"part-000",是否可以编写某种扩展名来重命名各个输出文件名(例如每个窗口文件名) Apache Beam?
为此,可能必须能够为窗口指定名称或根据窗口的内容推断文件名.我想知道这种方法是否可行.
至于解决方案应该是流式还是批量式,流式模式示例是优选的
我有一个Dataflow作业要写入BigQuery.它适用于非嵌套模式,但嵌套模式失败.
这是我的Dataflow管道:
pipeline_options = PipelineOptions()
p = beam.Pipeline(options=pipeline_options)
wordcount_options = pipeline_options.view_as(WordcountTemplatedOptions)
schema = 'url: STRING,' \
'ua: STRING,' \
'method: STRING,' \
'man: RECORD,' \
'man.ip: RECORD,' \
'man.ip.cc: STRING,' \
'man.ip.city: STRING,' \
'man.ip.as: INTEGER,' \
'man.ip.country: STRING,' \
'man.res: RECORD,' \
'man.res.ip_dom: STRING'
first = p | 'read' >> ReadFromText(wordcount_options.input)
second = (first
| 'process' >> (beam.ParDo(processFunction()))
| 'write' >> beam.io.WriteToBigQuery(
'myBucket:tableFolder.test_table',
schema=schema)
)
Run Code Online (Sandbox Code Playgroud)
我使用以下Schema创建了BigQuery Table:
[
{
"mode": "NULLABLE",
"name": "url",
"type": "STRING"
},
{
"mode": "NULLABLE", …Run Code Online (Sandbox Code Playgroud) python google-bigquery google-cloud-platform google-cloud-dataflow apache-beam
我正在使用我的Mac上的DirectRunner测试我的Dataflow管道并得到了很多像这样的"警告"消息,我可能知道如何摆脱它们,因为它太多了,我甚至看不到我的调试消息.
谢谢
Apr 05, 2018 2:14:48 PM org.apache.beam.sdk.util.MutationDetectors$CodedValueMutationDetector verifyUnmodifiedThrowingCheckedExceptions
WARNING: Coder of type class org.apache.beam.sdk.coders.SerializableCoder has a #structuralValue method which does not return true when the encoding of the elements is equal.
Element com.apigee.analytics.platform.core.service.schema.EventRow@4a590d0b
Run Code Online (Sandbox Code Playgroud)