Google cloud platform Google云数据流:CloudBigtableScanConfiguration.withScan(),如何传递动态筛选值?

Google cloud platform Google云数据流:CloudBigtableScanConfiguration.withScan(),如何传递动态筛选值?,google-cloud-platform,google-cloud-dataflow,Google Cloud Platform,Google Cloud Dataflow,SourceLocation是my Bigtable的前缀,它是从application.properties获取的。在运行数据流模板时,是否有方法动态获取它 我的管道: pipeline.apply("ReadTable", Read.from(CloudBigtableIO.read(configSetUp(options)))) CloudBigtableScanConfiguration private static CloudBigtableScanConfiguration con

SourceLocation是my Bigtable的前缀,它是从application.properties获取的。在运行数据流模板时,是否有方法动态获取它

我的管道:

pipeline.apply("ReadTable", Read.from(CloudBigtableIO.read(configSetUp(options))))
CloudBigtableScanConfiguration

private static CloudBigtableScanConfiguration configSetUp(LocationSetupOptions options) {
    ValueProvider<Integer>  pageFilter = options.getPageFilter();
    Scan scan = new Scan(Bytes.toBytes(options.getSourceLocation().get()));

    FilterList filterList = new FilterList();
    PrefixFilter prefixFilter = new PrefixFilter(Bytes.toBytes(options.getSourceLocation().get()));
    filterList.addFilter(new PageFilter(Long.valueOf(pageFilter.get())));
    filterList.addFilter(prefixFilter);
    scan.setFilter(filterList);

    return new CloudBigtableScanConfiguration.Builder()
        .withProjectId(options.getProjectId())
        .withInstanceId(options.getInstanceId())
        .withTableId(options.getTableId())
        .withScan(scan)
        .build();}
私有静态CloudBigtableScanConfiguration配置设置(位置设置选项){
ValueProvider pageFilter=options.getPageFilter();
扫描=新扫描(Bytes.toBytes(options.getSourceLocation().get());
FilterList FilterList=新的FilterList();
PrefixFilter PrefixFilter=新的PrefixFilter(Bytes.toBytes(options.getSourceLocation().get());
filterList.addFilter(新的页面过滤器(Long.valueOf(PageFilter.get()));
filterList.addFilter(prefixFilter);
scan.setFilter(过滤器列表);
返回新的CloudBigtableScanConfiguration.Builder()
.withProjectId(options.getProjectId())
.withInstanceId(options.getInstanceId())
.withTableId(options.getTableId())
.扫描(扫描)
.build();}

Bigtable
CloudBigtableIO
BigtableIO
有两个客户端。CloudBigtableIO参数不会更新为通过ValueProvider由模板修改,但BigtableIO与ValueProviders兼容

在您的特定情况下,如果您正在寻找与模板一起使用的
ValueProvider
,那么我建议您使用
BigtableIO
。可以在这里找到一个样本

更新 可以使用指定用户提供的工厂方法来生成参数的默认值。这样,您就可以从DefaultValueFactory实现内部的资源文件中读取默认值


例如,您可以检查如何定义DefaultToCurrentSystemTime来注释minTimestampMillis参数:

谢谢您的响应。我能够将ValueProvider与CloudBigtableIO一起使用。在构造模板时,BigTable前缀从应用程序属性中提取。在执行模板时是否有方法传递运行时前缀?感谢您的回复我已经更新了答案。如果这有帮助,请接受答案。我有一个类似的实现来从应用程序属性获取默认值。我们的管道使用特定的输入查询Bigtable,处理结果并插入到另一个表中。在执行管道模板时,我面临为大表查询传递动态输入的问题。感谢您的回复