本文整理汇总了Java中com.google.cloud.dataflow.sdk.transforms.DoFnTester.setSideInputInGlobalWindow方法的典型用法代码示例。如果您正苦于以下问题:Java DoFnTester.setSideInputInGlobalWindow方法的具体用法?Java DoFnTester.setSideInputInGlobalWindow怎么用?Java DoFnTester.setSideInputInGlobalWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.cloud.dataflow.sdk.transforms.DoFnTester
的用法示例。
在下文中一共展示了DoFnTester.setSideInputInGlobalWindow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCSVToMapLineCombineFn
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testCSVToMapLineCombineFn() {
final String[] csv = new String[] {
"000,Tokyo,120",
"001,Osaka,100",
"002,Kyoto,140"
};
final List<String> csvlist = Arrays.asList(csv);
Pipeline p = TestPipeline.create();
PCollection<String> maplines = p.apply(Create.of(csvlist)).setCoder(StringUtf8Coder.of());
PCollectionView<Map<String,String>> mapview = maplines.apply(Combine.globally(new CSVToMapLineCombineFn()).asSingletonView());
final String[] dummy = new String[] {
"000",
"001",
"002"
};
List<String> dummylist = Arrays.asList(dummy);
DoFnTester<String,String> fnTester = DoFnTester.of(new AAA(mapview));
fnTester.setSideInputInGlobalWindow(mapview, csvlist);
//dummylines.apply(ParDo.of(fnTester));
List<String> results = fnTester.processBatch(dummylist);
System.out.println(results);
//p.apply()
}
示例2: testFilterStateNoMatchingResources
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateNoMatchingResources() {
GCPProject checkedProject = getSampleProject("_checked");
GCPProject liveProject = getSampleProject("_live");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(checkedProject, 1);
GCPResourceState livePolicy = getSampleGCPResourcePolicy(liveProject, 2);
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) checkedProject, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) liveProject, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
FilterOutMatchingState function = new FilterOutMatchingState(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(0, results.size());
}
示例3: testFilterStateNoMismatches
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateNoMismatches() {
GCPProject project = getSampleProject("");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(project, 1);
GCPResourceState livePolicy = checkedPolicy;
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
FilterOutMatchingState function = new FilterOutMatchingState(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(0, results.size());
}
示例4: testFilterStateOneMismatch
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateOneMismatch() {
GCPProject project = getSampleProject("");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(project, 1);
GCPResourceState livePolicy = getSampleGCPResourcePolicy(project, 2);
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
FilterOutMatchingState function = new FilterOutMatchingState(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
Map<StateSource, GCPResourceState> outputMap = new HashMap<>(2);
outputMap.put(StateSource.DESIRED, checkedPolicy);
outputMap.put(StateSource.LIVE, livePolicy);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> expectedOutput =
Arrays.asList(KV.of((GCPResource) project, outputMap));
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(expectedOutput, results);
}
示例5: testFilterStateNoMatchingResources
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateNoMatchingResources() {
GCPProject checkedProject = getSampleProject("_checked");
GCPProject liveProject = getSampleProject("_live");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(checkedProject, 1);
GCPResourceState livePolicy = getSampleGCPResourcePolicy(liveProject, 2);
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) checkedProject, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) liveProject, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
JoinKnownGoodAndLiveStates function = new JoinKnownGoodAndLiveStates(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(0, results.size());
}
示例6: testFilterStateNoMismatches
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateNoMismatches() {
GCPProject project = getSampleProject("");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(project, 1);
GCPResourceState livePolicy = checkedPolicy;
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
JoinKnownGoodAndLiveStates function = new JoinKnownGoodAndLiveStates(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(1, results.size());
}
示例7: testFilterStateOneMismatch
import com.google.cloud.dataflow.sdk.transforms.DoFnTester; //导入方法依赖的package包/类
@Test
public void testFilterStateOneMismatch() {
GCPProject project = getSampleProject("");
GCPResourceState checkedPolicy = getSampleGCPResourcePolicy(project, 1);
GCPResourceState livePolicy = getSampleGCPResourcePolicy(project, 2);
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> sideInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.DESIRED, checkedPolicy)));
List<KV<GCPResource, KV<StateSource, GCPResourceState>>> mainInputList =
Arrays.asList(KV.of((GCPResource) project, KV.of(StateSource.LIVE, livePolicy)));
PCollection<KV<GCPResource, KV<StateSource, GCPResourceState>>> collection =
pipeline.apply(Create.of(sideInputList)).setCoder(
KvCoder.of(SerializableCoder.of(GCPResource.class),
KvCoder.of(SerializableCoder.of(StateSource.class),
SerializableCoder.of(GCPResourceState.class))));
PCollectionView<Map<GCPResource, KV<StateSource, GCPResourceState>>> view =
View.<GCPResource, KV<StateSource, GCPResourceState>>asMap().apply(collection);
JoinKnownGoodAndLiveStates function = new JoinKnownGoodAndLiveStates(view);
DoFnTester<KV<GCPResource, KV<StateSource, GCPResourceState>>,
KV<GCPResource, Map<StateSource, GCPResourceState>>> tester = DoFnTester.of(function);
tester.setSideInputInGlobalWindow(view, sideInputList);
Map<StateSource, GCPResourceState> outputMap = new HashMap<>(2);
outputMap.put(StateSource.DESIRED, checkedPolicy);
outputMap.put(StateSource.LIVE, livePolicy);
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> expectedOutput =
Arrays.asList(KV.of((GCPResource) project, outputMap));
List<KV<GCPResource, Map<StateSource, GCPResourceState>>> results =
tester.processBatch(mainInputList);
assertEquals(expectedOutput, results);
}