【问题标题】:Apache beam pipeline Java : Records not writing to the destination file in sequential orderApache梁管道Java:记录未按顺序写入目标文件
【发布时间】:2021-07-26 18:08:55
【问题描述】:

我正在使用 Apache Beam 管道将 csv 文件从一个容器传输到 Azure 存储中的另一个容器,并且能够成功传输文件,但目标文件中的记录不是按顺序排列的。下面是我用来传输文件的代码。

String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY_MM_DD_HH_MM_SS3")).toString();

String connectionString = "<<AZURE_STORAGE_CONNECTION_STRING>>"; 
        
PipelineOptions options = PipelineOptionsFactory.create();
options.as(BlobstoreOptions.class).setAzureConnectionString(connectionString);
        
Pipeline p = Pipeline.create(options);
p.apply(TextIO.read().from("azfs://storageaccountname/containername/CSVSample.csv"))
.apply("",FileIO.<String>write().to("azfs://storageaccountname/containername/"+format+"/").withNumShards(1).withSuffix(".csv")
        .via(TextIO.sink()));
p.run().waitUntilFinish();

【问题讨论】:

    标签: azure-blob-storage google-cloud-dataflow apache-beam dataflow apache-beam-io


    【解决方案1】:

    Beam PCollection 没有排序。如果您需要排序,您可以group by a key(在其中强制排序)并对值集进行排序,将其作为包含换行符的单个字符串元素发出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-29
      • 2023-03-07
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      相关资源
      最近更新 更多