Apache光束管道Java:记录未按顺序写入目标文件



我正在使用Apache束管道将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();

Beam PCollections未排序。如果需要排序,可以通过一个键(在其中施加顺序(进行分组,并对值集进行排序,将其作为包含换行符的单个字符串元素发出。

最新更新