从Apache Beam中的ValueProvider提取值 [英] Extract value from ValueProvider in Apache Beam

查看:129
本文介绍了从Apache Beam中的ValueProvider提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Apache Beam程序中获得了一个运行时值.我需要访问该值,但Beam不允许我读取该值,除非我从类似ParDo的转换中读取它.

I have a runtime value that I'm getting in my Apache Beam program. I need to access that value but Beam does not allow me to read that value unless I'm reading it from within a transfrom like ParDo.

如果我尝试在任何转换之外访问该值,则会给我一个错误消息: 未从运行时上下文中调用".

If I try to access that value outside any transform, it gives me an error saying: "Not called from a runtime context".

如何读取这些值?

P.S.我正在使用该程序的模板.

P.S. I'm using a template of the program.

推荐答案

程序(例如模板)分两个阶段执行.首先,评估主要方法以产生管道结构.这代表模板.在第二阶段,执行该管道结构.

A program (such as a template) is executed in two stages. In the first, the main method is evaluated to produce a pipeline structure. This represents the template. In the second stage, that pipeline structure is executed.

在评估期间(在用户定义的函数(如DoFn之类)之外)访问ValueProvider是不可能的,因为直到第二阶段才提供运行时值.

Accessing a ValueProvider during evaluation (outside of a user-defined function like a DoFn) is imposible, because the runtime values aren't provided until the second stage.

您能详细说明您要做什么吗?通常,解决方案是使ValueProvider可用于DoFn,然后让DoFn在运行时评估ValueProvider.

Could you elaborate on what you are trying to do? Generally, the solution is to make the ValueProvider available to the DoFn, and then have the DoFn evaluate the ValueProvider at runtime.

这篇关于从Apache Beam中的ValueProvider提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆