FileIO { public static <DestT, InputT> Write<DestT, InputT> writeDynamic() { return new AutoValue_FileIO_Write.Builder<DestT, InputT>() .setDynamic(true) .setCompression(Compression.UNCOMPRESSED) .setIgnoreWindowing(false) .setNoSpilling(false) .build(); }  static Match match(); static MatchAll matchAll(); static ReadMatches readMatches(); static Write<Void, InputT> write(); static Write<DestT, InputT> writeDynamic();  }
@Test @Category(NeedsRunner.class) public void testFileIoDynamicNaming() throws IOException { String outputFileName = tmpFolder.newFile().getAbsolutePath(); PCollectionView<String> outputFileNameView = p.apply("outputFileName", Create.of(outputFileName)).apply(View.asSingleton()); Contextful.Fn<String, FileIO.Write.FileNaming> fileNaming = (element, c) -> (window, pane, numShards, shardIndex, compression) -> c.sideInput(outputFileNameView) + "-" + shardIndex; p.apply(Create.of("")) .apply( "WriteDynamicFilename", FileIO.<String, String>writeDynamic() .by(SerializableFunctions.constant("")) .withDestinationCoder(StringUtf8Coder.of()) .via(TextIO.sink()) .withTempDirectory(tmpFolder.newFolder().getAbsolutePath()) .withNaming( Contextful.of( fileNaming, Requirements.requiresSideInputs(outputFileNameView)))); p.run(PipelineOptionsFactory.create()).waitUntilFinish(); assertTrue( "Output file shard 0 exists after pipeline completes", new File(outputFileName + "-0").exists()); }