org.apache.flink.api.common.operators.BinaryOperatorInformation Java Examples

The following examples show how to use org.apache.flink.api.common.operators.BinaryOperatorInformation. 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: PlanLeftUnwrappingCoGroupOperator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public PlanLeftUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		Keys.SelectorFunctionKeys<I1, K> key1,
		int[] key2,
		String name,
		TypeInformation<OUT> resultType,
		TypeInformation<Tuple2<K, I1>> typeInfoWithKey1,
		TypeInformation<I2> typeInfo2) {

	super(
			new TupleLeftUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<Tuple2<K, I1>, I2, OUT>(
					typeInfoWithKey1,
					typeInfo2,
					resultType),
			key1.computeLogicalKeyPositions(),
			key2,
			name);
}
 
Example #2
Source File: PlanRightUnwrappingCoGroupOperator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
public PlanRightUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		int[] key1,
		Keys.SelectorFunctionKeys<I2, K> key2,
		String name,
		TypeInformation<OUT> resultType,
		TypeInformation<I1> typeInfo1,
		TypeInformation<Tuple2<K, I2>> typeInfoWithKey2) {

	super(
			new TupleRightUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<I1, Tuple2<K, I2>, OUT>(
					typeInfo1,
					typeInfoWithKey2,
					resultType),
			key1,
			key2.computeLogicalKeyPositions(),
			name);
}
 
Example #3
Source File: CrossOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> translateToDataFlow(Operator<I1> input1, Operator<I2> input2) {

	String name = getName() != null ? getName() : "Cross at " + defaultName;
	// create operator
	CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> po =
			new CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>>(function,
					new BinaryOperatorInformation<I1, I2, OUT>(getInput1Type(), getInput2Type(), getResultType()),
					name);

	po.setFirstInput(input1);
	po.setSecondInput(input2);
	po.setParallelism(getParallelism());
	po.setCrossHint(hint);

	return po;
}
 
Example #4
Source File: CrossOperator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> translateToDataFlow(Operator<I1> input1, Operator<I2> input2) {

	String name = getName() != null ? getName() : "Cross at " + defaultName;
	// create operator
	CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> po =
			new CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>>(function,
					new BinaryOperatorInformation<I1, I2, OUT>(getInput1Type(), getInput2Type(), getResultType()),
					name);

	po.setFirstInput(input1);
	po.setSecondInput(input2);
	po.setParallelism(getParallelism());
	po.setCrossHint(hint);

	return po;
}
 
Example #5
Source File: PlanBothUnwrappingCoGroupOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanBothUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		Keys.SelectorFunctionKeys<I1, K> key1,
		Keys.SelectorFunctionKeys<I2, K> key2,
		String name,
		TypeInformation<OUT> type,
		TypeInformation<Tuple2<K, I1>> typeInfoWithKey1,
		TypeInformation<Tuple2<K, I2>> typeInfoWithKey2) {

	super(
			new TupleBothUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<Tuple2<K, I1>, Tuple2<K, I2>, OUT>(
					typeInfoWithKey1,
					typeInfoWithKey2,
					type),
			key1.computeLogicalKeyPositions(),
			key2.computeLogicalKeyPositions(),
			name);
}
 
Example #6
Source File: PlanRightUnwrappingCoGroupOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanRightUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		int[] key1,
		Keys.SelectorFunctionKeys<I2, K> key2,
		String name,
		TypeInformation<OUT> resultType,
		TypeInformation<I1> typeInfo1,
		TypeInformation<Tuple2<K, I2>> typeInfoWithKey2) {

	super(
			new TupleRightUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<I1, Tuple2<K, I2>, OUT>(
					typeInfo1,
					typeInfoWithKey2,
					resultType),
			key1,
			key2.computeLogicalKeyPositions(),
			name);
}
 
Example #7
Source File: PlanLeftUnwrappingCoGroupOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanLeftUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		Keys.SelectorFunctionKeys<I1, K> key1,
		int[] key2,
		String name,
		TypeInformation<OUT> resultType,
		TypeInformation<Tuple2<K, I1>> typeInfoWithKey1,
		TypeInformation<I2> typeInfo2) {

	super(
			new TupleLeftUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<Tuple2<K, I1>, I2, OUT>(
					typeInfoWithKey1,
					typeInfo2,
					resultType),
			key1.computeLogicalKeyPositions(),
			key2,
			name);
}
 
Example #8
Source File: PlanRightUnwrappingCoGroupOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanRightUnwrappingCoGroupOperator(
		CoGroupFunction<I1, I2, OUT> udf,
		int[] key1,
		Keys.SelectorFunctionKeys<I2, K> key2,
		String name,
		TypeInformation<OUT> resultType,
		TypeInformation<I1> typeInfo1,
		TypeInformation<Tuple2<K, I2>> typeInfoWithKey2) {

	super(
			new TupleRightUnwrappingCoGrouper<I1, I2, OUT, K>(udf),
			new BinaryOperatorInformation<I1, Tuple2<K, I2>, OUT>(
					typeInfo1,
					typeInfoWithKey2,
					resultType),
			key1,
			key2.computeLogicalKeyPositions(),
			name);
}
 
Example #9
Source File: OuterJoinOperatorBaseTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Before
public void setup() {
	joiner = new MockRichFlatJoinFunction();

	baseOperator =
		new OuterJoinOperatorBase(joiner,
			new BinaryOperatorInformation(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,
				BasicTypeInfo.STRING_TYPE_INFO), new int[0], new int[0], "TestJoiner", null);

	executionConfig = new ExecutionConfig();

	String taskName = "Test rich outer join function";
	TaskInfo taskInfo = new TaskInfo(taskName, 1, 0, 1, 0);
	HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<>();
	HashMap<String, Future<Path>> cpTasks = new HashMap<>();

	runtimeContext = new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks,
		accumulatorMap, new UnregisteredMetricsGroup());
}
 
Example #10
Source File: CrossOperator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> translateToDataFlow(Operator<I1> input1, Operator<I2> input2) {

	String name = getName() != null ? getName() : "Cross at " + defaultName;
	// create operator
	CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>> po =
			new CrossOperatorBase<I1, I2, OUT, CrossFunction<I1, I2, OUT>>(function,
					new BinaryOperatorInformation<I1, I2, OUT>(getInput1Type(), getInput2Type(), getResultType()),
					name);

	po.setFirstInput(input1);
	po.setSecondInput(input2);
	po.setParallelism(getParallelism());
	po.setCrossHint(hint);

	return po;
}
 
Example #11
Source File: OuterJoinOperatorBaseTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Before
public void setup() {
	joiner = new MockRichFlatJoinFunction();

	baseOperator =
		new OuterJoinOperatorBase(joiner,
			new BinaryOperatorInformation(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,
				BasicTypeInfo.STRING_TYPE_INFO), new int[0], new int[0], "TestJoiner", null);

	executionConfig = new ExecutionConfig();

	String taskName = "Test rich outer join function";
	TaskInfo taskInfo = new TaskInfo(taskName, 1, 0, 1, 0);
	HashMap<String, Accumulator<?, ?>> accumulatorMap = new HashMap<>();
	HashMap<String, Future<Path>> cpTasks = new HashMap<>();

	runtimeContext = new RuntimeUDFContext(taskInfo, null, executionConfig, cpTasks,
		accumulatorMap, new UnregisteredMetricsGroup());
}
 
Example #12
Source File: OperatorTranslation.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private <D, W> DeltaIterationBase<D, W> translateDeltaIteration(DeltaIterationResultSet<?, ?> untypedIterationEnd) {
	@SuppressWarnings("unchecked")
	DeltaIterationResultSet<D, W> iterationEnd = (DeltaIterationResultSet<D, W>) untypedIterationEnd;
	DeltaIteration<D, W> iterationHead = iterationEnd.getIterationHead();

	String name = iterationHead.getName() == null ? "Unnamed Delta Iteration" : iterationHead.getName();

	DeltaIterationBase<D, W> iterationOperator = new DeltaIterationBase<>(new BinaryOperatorInformation<>(iterationEnd.getType(), iterationEnd.getWorksetType(), iterationEnd.getType()),
			iterationEnd.getKeyPositions(), name);

	iterationOperator.setMaximumNumberOfIterations(iterationEnd.getMaxIterations());

	if (iterationHead.getParallelism() > 0) {
		iterationOperator.setParallelism(iterationHead.getParallelism());
	}

	DeltaIteration.SolutionSetPlaceHolder<D> solutionSetPlaceHolder = iterationHead.getSolutionSet();
	DeltaIteration.WorksetPlaceHolder<W> worksetPlaceHolder = iterationHead.getWorkset();

	translated.put(solutionSetPlaceHolder, iterationOperator.getSolutionSet());
	translated.put(worksetPlaceHolder, iterationOperator.getWorkset());

	Operator<D> translatedSolutionSet = translate(iterationEnd.getNextSolutionSet());
	Operator<W> translatedWorkset = translate(iterationEnd.getNextWorkset());

	iterationOperator.setNextWorkset(translatedWorkset);
	iterationOperator.setSolutionSetDelta(translatedSolutionSet);

	iterationOperator.setInitialSolutionSet(translate(iterationHead.getInitialSolutionSet()));
	iterationOperator.setInitialWorkset(translate(iterationHead.getInitialWorkset()));

	// register all aggregators
	iterationOperator.getAggregators().addAll(iterationHead.getAggregators());

	iterationOperator.setSolutionSetUnManaged(iterationHead.isSolutionSetUnManaged());

	return iterationOperator;
}
 
Example #13
Source File: OperatorTranslation.java    From flink with Apache License 2.0 5 votes vote down vote up
private <D, W> DeltaIterationBase<D, W> translateDeltaIteration(DeltaIterationResultSet<?, ?> untypedIterationEnd) {
	@SuppressWarnings("unchecked")
	DeltaIterationResultSet<D, W> iterationEnd = (DeltaIterationResultSet<D, W>) untypedIterationEnd;
	DeltaIteration<D, W> iterationHead = iterationEnd.getIterationHead();

	String name = iterationHead.getName() == null ? "Unnamed Delta Iteration" : iterationHead.getName();

	DeltaIterationBase<D, W> iterationOperator = new DeltaIterationBase<>(new BinaryOperatorInformation<>(iterationEnd.getType(), iterationEnd.getWorksetType(), iterationEnd.getType()),
			iterationEnd.getKeyPositions(), name);

	iterationOperator.setMaximumNumberOfIterations(iterationEnd.getMaxIterations());

	if (iterationHead.getParallelism() > 0) {
		iterationOperator.setParallelism(iterationHead.getParallelism());
	}

	DeltaIteration.SolutionSetPlaceHolder<D> solutionSetPlaceHolder = iterationHead.getSolutionSet();
	DeltaIteration.WorksetPlaceHolder<W> worksetPlaceHolder = iterationHead.getWorkset();

	translated.put(solutionSetPlaceHolder, iterationOperator.getSolutionSet());
	translated.put(worksetPlaceHolder, iterationOperator.getWorkset());

	Operator<D> translatedSolutionSet = translate(iterationEnd.getNextSolutionSet());
	Operator<W> translatedWorkset = translate(iterationEnd.getNextWorkset());

	iterationOperator.setNextWorkset(translatedWorkset);
	iterationOperator.setSolutionSetDelta(translatedSolutionSet);

	iterationOperator.setInitialSolutionSet(translate(iterationHead.getInitialSolutionSet()));
	iterationOperator.setInitialWorkset(translate(iterationHead.getInitialWorkset()));

	// register all aggregators
	iterationOperator.getAggregators().addAll(iterationHead.getAggregators());

	iterationOperator.setSolutionSetUnManaged(iterationHead.isSolutionSetUnManaged());

	return iterationOperator;
}
 
Example #14
Source File: InnerJoinOperatorBaseTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinPlain(){
	final FlatJoinFunction<String, String, Integer> joiner = new FlatJoinFunction<String, String, Integer>() {

		@Override
		public void join(String first, String second, Collector<Integer> out) throws Exception {
			out.collect(first.length());
			out.collect(second.length());
		}
	};

	@SuppressWarnings({ "rawtypes", "unchecked" })
	InnerJoinOperatorBase<String, String, Integer,
					FlatJoinFunction<String, String,Integer> > base = new InnerJoinOperatorBase(joiner,
			new BinaryOperatorInformation(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,
					BasicTypeInfo.INT_TYPE_INFO), new int[0], new int[0], "TestJoiner");

	List<String> inputData1 = new ArrayList<String>(Arrays.asList("foo", "bar", "foobar"));
	List<String> inputData2 = new ArrayList<String>(Arrays.asList("foobar", "foo"));
	List<Integer> expected = new ArrayList<Integer>(Arrays.asList(3, 3, 6 ,6));

	try {
		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<Integer> resultSafe = base.executeOnCollections(inputData1, inputData2, null, executionConfig);
		executionConfig.enableObjectReuse();
		List<Integer> resultRegular = base.executeOnCollections(inputData1, inputData2, null, executionConfig);

		assertEquals(expected, resultSafe);
		assertEquals(expected, resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #15
Source File: CrossOperatorBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public CrossOperatorBase(UserCodeWrapper<FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
	super(udf, operatorInfo, name);
	
	if (this instanceof CrossWithSmall) {
		setCrossHint(CrossHint.SECOND_IS_SMALL);
	}
	else if (this instanceof CrossWithLarge) {
		setCrossHint(CrossHint.FIRST_IS_SMALL);
	}
}
 
Example #16
Source File: CoGroupOperatorCollectionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private CoGroupOperatorBase<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>, CoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>>> getCoGroupOperator(
		RichCoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>, Tuple2<String, Integer>> udf) {

	TypeInformation<Tuple2<String, Integer>> tuple2Info = TypeInformation.of(new TypeHint<Tuple2<String, Integer>>(){});

	return new CoGroupOperatorBase<>(
			udf,
			new BinaryOperatorInformation<>(tuple2Info, tuple2Info, tuple2Info),
			new int[]{0},
			new int[]{0},
			"coGroup on Collections"
	);
}
 
Example #17
Source File: CoGroupOperatorCollectionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private CoGroupOperatorBase<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>, CoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>>> getCoGroupOperator(
		RichCoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>, Tuple2<String, Integer>> udf) {

	TypeInformation<Tuple2<String, Integer>> tuple2Info = TypeInformation.of(new TypeHint<Tuple2<String, Integer>>(){});

	return new CoGroupOperatorBase<>(
			udf,
			new BinaryOperatorInformation<>(tuple2Info, tuple2Info, tuple2Info),
			new int[]{0},
			new int[]{0},
			"coGroup on Collections"
	);
}
 
Example #18
Source File: InnerJoinOperatorBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinPlain(){
	final FlatJoinFunction<String, String, Integer> joiner = new FlatJoinFunction<String, String, Integer>() {

		@Override
		public void join(String first, String second, Collector<Integer> out) throws Exception {
			out.collect(first.length());
			out.collect(second.length());
		}
	};

	@SuppressWarnings({ "rawtypes", "unchecked" })
	InnerJoinOperatorBase<String, String, Integer,
					FlatJoinFunction<String, String,Integer> > base = new InnerJoinOperatorBase(joiner,
			new BinaryOperatorInformation(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,
					BasicTypeInfo.INT_TYPE_INFO), new int[0], new int[0], "TestJoiner");

	List<String> inputData1 = new ArrayList<String>(Arrays.asList("foo", "bar", "foobar"));
	List<String> inputData2 = new ArrayList<String>(Arrays.asList("foobar", "foo"));
	List<Integer> expected = new ArrayList<Integer>(Arrays.asList(3, 3, 6 ,6));

	try {
		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<Integer> resultSafe = base.executeOnCollections(inputData1, inputData2, null, executionConfig);
		executionConfig.enableObjectReuse();
		List<Integer> resultRegular = base.executeOnCollections(inputData1, inputData2, null, executionConfig);

		assertEquals(expected, resultSafe);
		assertEquals(expected, resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #19
Source File: JoinOperator.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public JoinOperatorBase<?, ?, OUT, ?> build() {
	JoinOperatorBase<?, ?, OUT, ?> operator;
	if (joinType.isOuter()) {
		operator = new OuterJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name,
				getOuterJoinType());
	} else {
		operator = new InnerJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name);
	}

	operator.setFirstInput(input1);
	operator.setSecondInput(input2);
	operator.setParallelism(parallelism);
	operator.setCustomPartitioner(partitioner);
	operator.setJoinHint(joinHint);
	return operator;
}
 
Example #20
Source File: CoGroupOperatorCollectionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private CoGroupOperatorBase<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>, CoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>,
		Tuple2<String, Integer>>> getCoGroupOperator(
		RichCoGroupFunction<Tuple2<String, Integer>, Tuple2<String, Integer>, Tuple2<String, Integer>> udf) {

	TypeInformation<Tuple2<String, Integer>> tuple2Info = TypeInformation.of(new TypeHint<Tuple2<String, Integer>>(){});

	return new CoGroupOperatorBase<>(
			udf,
			new BinaryOperatorInformation<>(tuple2Info, tuple2Info, tuple2Info),
			new int[]{0},
			new int[]{0},
			"coGroup on Collections"
	);
}
 
Example #21
Source File: CrossOperatorBase.java    From flink with Apache License 2.0 5 votes vote down vote up
public CrossOperatorBase(UserCodeWrapper<FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
	super(udf, operatorInfo, name);
	
	if (this instanceof CrossWithSmall) {
		setCrossHint(CrossHint.SECOND_IS_SMALL);
	}
	else if (this instanceof CrossWithLarge) {
		setCrossHint(CrossHint.FIRST_IS_SMALL);
	}
}
 
Example #22
Source File: InnerJoinOperatorBaseTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinPlain(){
	final FlatJoinFunction<String, String, Integer> joiner = new FlatJoinFunction<String, String, Integer>() {

		@Override
		public void join(String first, String second, Collector<Integer> out) throws Exception {
			out.collect(first.length());
			out.collect(second.length());
		}
	};

	@SuppressWarnings({ "rawtypes", "unchecked" })
	InnerJoinOperatorBase<String, String, Integer,
					FlatJoinFunction<String, String,Integer> > base = new InnerJoinOperatorBase(joiner,
			new BinaryOperatorInformation(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO,
					BasicTypeInfo.INT_TYPE_INFO), new int[0], new int[0], "TestJoiner");

	List<String> inputData1 = new ArrayList<String>(Arrays.asList("foo", "bar", "foobar"));
	List<String> inputData2 = new ArrayList<String>(Arrays.asList("foobar", "foo"));
	List<Integer> expected = new ArrayList<Integer>(Arrays.asList(3, 3, 6 ,6));

	try {
		ExecutionConfig executionConfig = new ExecutionConfig();
		executionConfig.disableObjectReuse();
		List<Integer> resultSafe = base.executeOnCollections(inputData1, inputData2, null, executionConfig);
		executionConfig.enableObjectReuse();
		List<Integer> resultRegular = base.executeOnCollections(inputData1, inputData2, null, executionConfig);

		assertEquals(expected, resultSafe);
		assertEquals(expected, resultRegular);
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #23
Source File: OperatorTranslation.java    From flink with Apache License 2.0 5 votes vote down vote up
private <D, W> DeltaIterationBase<D, W> translateDeltaIteration(DeltaIterationResultSet<?, ?> untypedIterationEnd) {
	@SuppressWarnings("unchecked")
	DeltaIterationResultSet<D, W> iterationEnd = (DeltaIterationResultSet<D, W>) untypedIterationEnd;
	DeltaIteration<D, W> iterationHead = iterationEnd.getIterationHead();

	String name = iterationHead.getName() == null ? "Unnamed Delta Iteration" : iterationHead.getName();

	DeltaIterationBase<D, W> iterationOperator = new DeltaIterationBase<>(new BinaryOperatorInformation<>(iterationEnd.getType(), iterationEnd.getWorksetType(), iterationEnd.getType()),
			iterationEnd.getKeyPositions(), name);

	iterationOperator.setMaximumNumberOfIterations(iterationEnd.getMaxIterations());

	if (iterationHead.getParallelism() > 0) {
		iterationOperator.setParallelism(iterationHead.getParallelism());
	}

	DeltaIteration.SolutionSetPlaceHolder<D> solutionSetPlaceHolder = iterationHead.getSolutionSet();
	DeltaIteration.WorksetPlaceHolder<W> worksetPlaceHolder = iterationHead.getWorkset();

	translated.put(solutionSetPlaceHolder, iterationOperator.getSolutionSet());
	translated.put(worksetPlaceHolder, iterationOperator.getWorkset());

	Operator<D> translatedSolutionSet = translate(iterationEnd.getNextSolutionSet());
	Operator<W> translatedWorkset = translate(iterationEnd.getNextWorkset());

	iterationOperator.setNextWorkset(translatedWorkset);
	iterationOperator.setSolutionSetDelta(translatedSolutionSet);

	iterationOperator.setInitialSolutionSet(translate(iterationHead.getInitialSolutionSet()));
	iterationOperator.setInitialWorkset(translate(iterationHead.getInitialWorkset()));

	// register all aggregators
	iterationOperator.getAggregators().addAll(iterationHead.getAggregators());

	iterationOperator.setSolutionSetUnManaged(iterationHead.isSolutionSetUnManaged());

	return iterationOperator;
}
 
Example #24
Source File: JoinOperator.java    From flink with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public JoinOperatorBase<?, ?, OUT, ?> build() {
	JoinOperatorBase<?, ?, OUT, ?> operator;
	if (joinType.isOuter()) {
		operator = new OuterJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name,
				getOuterJoinType());
	} else {
		operator = new InnerJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name);
	}

	operator.setFirstInput(input1);
	operator.setSecondInput(input2);
	operator.setParallelism(parallelism);
	operator.setCustomPartitioner(partitioner);
	operator.setJoinHint(joinHint);
	return operator;
}
 
Example #25
Source File: JoinOperator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public JoinOperatorBase<?, ?, OUT, ?> build() {
	JoinOperatorBase<?, ?, OUT, ?> operator;
	if (joinType.isOuter()) {
		operator = new OuterJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name,
				getOuterJoinType());
	} else {
		operator = new InnerJoinOperatorBase<>(
				udf,
				new BinaryOperatorInformation(input1Type, input2Type, resultType),
				this.keys1.computeLogicalKeyPositions(),
				this.keys2.computeLogicalKeyPositions(),
				this.name);
	}

	operator.setFirstInput(input1);
	operator.setSecondInput(input2);
	operator.setParallelism(parallelism);
	operator.setCustomPartitioner(partitioner);
	operator.setJoinHint(joinHint);
	return operator;
}
 
Example #26
Source File: DeltaIterationBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DeltaIterationBase(BinaryOperatorInformation<ST, WT, ST> operatorInfo, int keyPosition, String name) {
	this(operatorInfo, new int[] {keyPosition}, name);
}
 
Example #27
Source File: OuterJoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public OuterJoinOperatorBase(UserCodeWrapper<FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo,
		int[] keyPositions1, int[] keyPositions2, String name, OuterJoinType outerJoinType) {
	super(udf, operatorInfo, keyPositions1, keyPositions2, name);
	this.outerJoinType = outerJoinType;
}
 
Example #28
Source File: JoinOperatorBase.java    From flink with Apache License 2.0 4 votes vote down vote up
public JoinOperatorBase(UserCodeWrapper<FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1, int[] keyPositions2, String name) {
	super(udf, operatorInfo, keyPositions1, keyPositions2, name);
}
 
Example #29
Source File: DeltaIterationBase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public DeltaIterationBase(BinaryOperatorInformation<ST, WT, ST> operatorInfo, int[] keyPositions) {
	this(operatorInfo, keyPositions, "<Unnamed Delta Iteration>");
}
 
Example #30
Source File: FeedbackPropertiesMatchTest.java    From flink with Apache License 2.0 4 votes vote down vote up
private static JoinNode getJoinNode() {
	return new JoinNode(new InnerJoinOperatorBase<String, String, String, FlatJoinFunction<String, String, String>>(new DummyFlatJoinFunction<String>(), new BinaryOperatorInformation<String, String, String>(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO), new int[] {1}, new int[] {2}, "join op"));
}