2017-07-24 33 views
1

這個問題是關於Google Dataflow的。我想用側面輸入測試一個do函數。谷歌手冊列表,你需要這樣的代碼:數據流 - 如何創建一個PCollectionView以與DoFnTester一起使用?

static class MyDoFn extends DoFn<String, Integer> { ... } 
    MyDoFn myDoFn = ...; 
    DoFnTester<String, Integer> fnTester = DoFnTester.of(myDoFn); 

    PCollectionView<List<Integer>> sideInput = ...; 
    Iterable<Integer> value = ...; 
    fnTester.setSideInputInGlobalWindow(sideInput, value); 

我想知道如何創建PCollectionView實例的代碼看起來像。在使用DoFnTester時,您沒有管道,我也沒有看到如何在沒有管道的情況下創建PCollectionView實例。你能告訴我如何創建一個用於DoFnTester的PCollectionView實例嗎?

謝謝你的時間。

隨着親切的問候,

的Martijn Dirkse

回答

0

,我發現自己的答案。您可以創建一個TestPipeline實例並使用它來構建您需要的PCollectionView。 TestPipeline在您的代碼中沒有任何其他目的是沒有問題的。

0

數據流2.1 sdk樣本here。在2.X中使用setSideInput代替setSideInputInGlobalWindow

相關問題