Java源码示例:org.apache.flink.runtime.operators.testutils.CollectionIterator
示例1
@SuppressWarnings("unchecked")
protected void testLeftOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例2
@SuppressWarnings("unchecked")
protected void testRightOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例3
@SuppressWarnings("unchecked")
protected void testRightSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of();
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", null, null),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", null, null)
);
Assert.assertEquals(expected, actualLeft);
Assert.assertEquals(expected, actualFull);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualRight);
}
示例4
@SuppressWarnings("unchecked")
protected void testLeftSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of();
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>(null, null, "Jack", 200),
new Tuple4<String, String, String, Object>(null, null, "Zed", 150),
new Tuple4<String, String, String, Object>(null, null, "Zed", 250)
);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualLeft);
Assert.assertEquals(expected, actualRight);
Assert.assertEquals(expected, actualFull);
}
示例5
@SuppressWarnings("unchecked")
protected void testLeftOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例6
@SuppressWarnings("unchecked")
protected void testRightOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例7
@SuppressWarnings("unchecked")
protected void testRightSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of();
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", null, null),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", null, null)
);
Assert.assertEquals(expected, actualLeft);
Assert.assertEquals(expected, actualFull);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualRight);
}
示例8
@SuppressWarnings("unchecked")
protected void testLeftSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of();
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>(null, null, "Jack", 200),
new Tuple4<String, String, String, Object>(null, null, "Zed", 150),
new Tuple4<String, String, String, Object>(null, null, "Zed", 250)
);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualLeft);
Assert.assertEquals(expected, actualRight);
Assert.assertEquals(expected, actualFull);
}
示例9
@SuppressWarnings("unchecked")
protected void testLeftOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例10
@SuppressWarnings("unchecked")
protected void testRightOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例11
@SuppressWarnings("unchecked")
protected void testRightSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of();
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>("Jack", "Engineering", null, null),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", null, null)
);
Assert.assertEquals(expected, actualLeft);
Assert.assertEquals(expected, actualFull);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualRight);
}
示例12
@SuppressWarnings("unchecked")
protected void testLeftSideEmpty() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of();
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
List<Tuple4<String, String, String, Object>> actualLeft = computeOuterJoin(input1, input2, OuterJoinType.LEFT);
List<Tuple4<String, String, String, Object>> actualRight = computeOuterJoin(input1, input2, OuterJoinType.RIGHT);
List<Tuple4<String, String, String, Object>> actualFull = computeOuterJoin(input1, input2, OuterJoinType.FULL);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>(null, null, "Jack", 200),
new Tuple4<String, String, String, Object>(null, null, "Zed", 150),
new Tuple4<String, String, String, Object>(null, null, "Zed", 250)
);
Assert.assertEquals(Collections.<Tuple4<String,String,String,Object>>emptyList(), actualLeft);
Assert.assertEquals(expected, actualRight);
Assert.assertEquals(expected, actualFull);
}
示例13
@SuppressWarnings("unchecked")
protected void testFullOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
OuterJoinType outerJoinType = OuterJoinType.FULL;
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, outerJoinType);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例14
@SuppressWarnings("unchecked")
protected void testFullOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
OuterJoinType outerJoinType = OuterJoinType.FULL;
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, outerJoinType);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}
示例15
@SuppressWarnings("unchecked")
protected void testFullOuterWithSample() throws Exception {
CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(
new Tuple2<>("Jack", "Engineering"),
new Tuple2<>("Tim", "Sales"),
new Tuple2<>("Zed", "HR")
);
CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(
new Tuple2<>("Allison", 100),
new Tuple2<>("Jack", 200),
new Tuple2<>("Zed", 150),
new Tuple2<>("Zed", 250)
);
OuterJoinType outerJoinType = OuterJoinType.FULL;
List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, outerJoinType);
List<Tuple4<String, String, String, Object>> expected = Arrays.asList(
new Tuple4<String, String, String, Object>(null, null, "Allison", 100),
new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200),
new Tuple4<String, String, String, Object>("Tim", "Sales", null, null),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150),
new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250)
);
Assert.assertEquals(expected, actual);
}