Java Code Examples for org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType#FULL

The following examples show how to use org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType#FULL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSortMergeOuterJoinIteratorITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: AbstractSortMergeOuterJoinIteratorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: AbstractSortMergeOuterJoinIteratorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: FullOuterJoinDriver.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new ReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
	case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
		return new ReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
	case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
		return new ReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}
 
Example 5
Source File: FullOuterJoinDriver.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getNonReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new NonReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
		case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
			return new NonReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
			return new NonReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}
 
Example 6
Source File: FullOuterJoinDriver.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new ReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
	case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
		return new ReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
	case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
		return new ReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}
 
Example 7
Source File: FullOuterJoinDriver.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getNonReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new NonReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
		case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
			return new NonReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
			return new NonReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}
 
Example 8
Source File: FullOuterJoinDriver.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new ReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
	case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
		return new ReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
	case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
		return new ReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}
 
Example 9
Source File: FullOuterJoinDriver.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JoinTaskIterator<IT1, IT2, OT> getNonReusingOuterJoinIterator(
		DriverStrategy driverStrategy,
		MutableObjectIterator<IT1> in1,
		MutableObjectIterator<IT2> in2,
		TypeSerializer<IT1> serializer1,
		TypeComparator<IT1> comparator1,
		TypeSerializer<IT2> serializer2,
		TypeComparator<IT2> comparator2,
		TypePairComparatorFactory<IT1, IT2> pairComparatorFactory,
		MemoryManager memoryManager,
		IOManager ioManager,
		double driverMemFraction
) throws Exception {
	switch (driverStrategy) {
		case FULL_OUTER_MERGE:
			int numPages = memoryManager.computeNumberOfPages(driverMemFraction);
			return new NonReusingMergeOuterJoinIterator<>(
					OuterJoinType.FULL,
					in1,
					in2,
					serializer1,
					comparator1,
					serializer2,
					comparator2,
					pairComparatorFactory.createComparator12(comparator1, comparator2),
					memoryManager,
					ioManager,
					numPages,
					super.taskContext.getContainingTask()
			);
		case FULL_OUTER_HYBRIDHASH_BUILD_FIRST:
			return new NonReusingBuildFirstHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator21(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		case FULL_OUTER_HYBRIDHASH_BUILD_SECOND:
			return new NonReusingBuildSecondHashJoinIterator<>(in1, in2,
				serializer1, comparator1,
				serializer2, comparator2,
				pairComparatorFactory.createComparator12(comparator1, comparator2),
				memoryManager, ioManager,
				this.taskContext.getContainingTask(),
				driverMemFraction,
				true,
				true,
				false);
		default:
			throw new Exception("Unsupported driver strategy for full outer join driver: " + driverStrategy.name());
	}
}