org.apache.flink.api.common.operators.base.InnerJoinOperatorBase Java Examples

The following examples show how to use org.apache.flink.api.common.operators.base.InnerJoinOperatorBase. 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: SemanticPropertiesProjectionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinProjectionSemProps1() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 3)
			.projectSecond(1, 4)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 2).size());
	assertEquals(1, props.getForwardingTargetFields(0, 3).size());
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 4).size());

	assertTrue(props.getForwardingTargetFields(0, 2).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 3).contains(1));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 4).contains(3));
}
 
Example #2
Source File: JoinNode.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new JoinNode for the given join operator.
 * 
 * @param joinOperatorBase The join operator object.
 */
public JoinNode(InnerJoinOperatorBase<?, ?, ?, ?> joinOperatorBase) {
	super(joinOperatorBase);
	
	this.dataProperties = getDataProperties(joinOperatorBase,
			joinOperatorBase.getJoinHint(), joinOperatorBase.getCustomPartitioner());
}
 
Example #3
Source File: SemanticPropertiesProjectionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinProjectionSemProps1() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 3)
			.projectSecond(1, 4)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 2).size());
	assertEquals(1, props.getForwardingTargetFields(0, 3).size());
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 4).size());

	assertTrue(props.getForwardingTargetFields(0, 2).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 3).contains(1));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 4).contains(3));
}
 
Example #4
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 #5
Source File: JoinNode.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new JoinNode for the given join operator.
 * 
 * @param joinOperatorBase The join operator object.
 */
public JoinNode(InnerJoinOperatorBase<?, ?, ?, ?> joinOperatorBase) {
	super(joinOperatorBase);
	
	this.dataProperties = getDataProperties(joinOperatorBase,
			joinOperatorBase.getJoinHint(), joinOperatorBase.getCustomPartitioner());
}
 
Example #6
Source File: SemanticPropertiesProjectionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinProjectionSemProps1() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 3)
			.projectSecond(1, 4)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 2).size());
	assertEquals(1, props.getForwardingTargetFields(0, 3).size());
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 4).size());

	assertTrue(props.getForwardingTargetFields(0, 2).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 3).contains(1));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 4).contains(3));
}
 
Example #7
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 #8
Source File: JoinNode.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new JoinNode for the given join operator.
 * 
 * @param joinOperatorBase The join operator object.
 */
public JoinNode(InnerJoinOperatorBase<?, ?, ?, ?> joinOperatorBase) {
	super(joinOperatorBase);
	
	this.dataProperties = getDataProperties(joinOperatorBase,
			joinOperatorBase.getJoinHint(), joinOperatorBase.getCustomPartitioner());
}
 
Example #9
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 #10
Source File: FeedbackPropertiesMatchTest.java    From Flink-CEPplus 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"));
}
 
Example #11
Source File: SemanticPropertiesProjectionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testJoinProjectionSemProps2() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 0)
			.projectSecond(1, 3)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 0).size());
	assertNotNull(props.getForwardingTargetFields(0, 1));
	assertNotNull(props.getForwardingTargetFields(0, 2));
	assertNotNull(props.getForwardingTargetFields(0, 3));
	assertEquals(1, props.getForwardingTargetFields(0, 4).size());
	assertEquals(1, props.getForwardingTargetFields(0, 5).size());
	assertNotNull(props.getForwardingTargetFields(0, 6));
	assertEquals(0, props.getForwardingTargetFields(0, 1).size());
	assertEquals(0, props.getForwardingTargetFields(0, 2).size());
	assertEquals(0, props.getForwardingTargetFields(0, 3).size());
	assertEquals(0, props.getForwardingTargetFields(0, 6).size());

	assertNotNull(props.getForwardingTargetFields(1, 0));
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 2).size());
	assertEquals(1, props.getForwardingTargetFields(1, 3).size());
	assertNotNull(props.getForwardingTargetFields(1, 4));
	assertNotNull(props.getForwardingTargetFields(1, 5));
	assertEquals(1, props.getForwardingTargetFields(1, 6).size());
	assertEquals(0, props.getForwardingTargetFields(1, 0).size());
	assertEquals(0, props.getForwardingTargetFields(1, 4).size());
	assertEquals(0, props.getForwardingTargetFields(1, 5).size());

	assertTrue(props.getForwardingTargetFields(0, 4).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 5).contains(1));
	assertTrue(props.getForwardingTargetFields(0, 0).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(3));
	assertTrue(props.getForwardingTargetFields(1, 2).contains(4));
	assertTrue(props.getForwardingTargetFields(1, 3).contains(5));
	assertTrue(props.getForwardingTargetFields(1, 6).contains(6));
}
 
Example #12
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"));
}
 
Example #13
Source File: SemanticPropertiesProjectionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testJoinProjectionSemProps2() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 0)
			.projectSecond(1, 3)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 0).size());
	assertNotNull(props.getForwardingTargetFields(0, 1));
	assertNotNull(props.getForwardingTargetFields(0, 2));
	assertNotNull(props.getForwardingTargetFields(0, 3));
	assertEquals(1, props.getForwardingTargetFields(0, 4).size());
	assertEquals(1, props.getForwardingTargetFields(0, 5).size());
	assertNotNull(props.getForwardingTargetFields(0, 6));
	assertEquals(0, props.getForwardingTargetFields(0, 1).size());
	assertEquals(0, props.getForwardingTargetFields(0, 2).size());
	assertEquals(0, props.getForwardingTargetFields(0, 3).size());
	assertEquals(0, props.getForwardingTargetFields(0, 6).size());

	assertNotNull(props.getForwardingTargetFields(1, 0));
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 2).size());
	assertEquals(1, props.getForwardingTargetFields(1, 3).size());
	assertNotNull(props.getForwardingTargetFields(1, 4));
	assertNotNull(props.getForwardingTargetFields(1, 5));
	assertEquals(1, props.getForwardingTargetFields(1, 6).size());
	assertEquals(0, props.getForwardingTargetFields(1, 0).size());
	assertEquals(0, props.getForwardingTargetFields(1, 4).size());
	assertEquals(0, props.getForwardingTargetFields(1, 5).size());

	assertTrue(props.getForwardingTargetFields(0, 4).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 5).contains(1));
	assertTrue(props.getForwardingTargetFields(0, 0).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(3));
	assertTrue(props.getForwardingTargetFields(1, 2).contains(4));
	assertTrue(props.getForwardingTargetFields(1, 3).contains(5));
	assertTrue(props.getForwardingTargetFields(1, 6).contains(6));
}
 
Example #14
Source File: SemanticPropertiesProjectionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testJoinProjectionSemProps2() {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple4<Integer, Tuple3<String, Integer, Long>, Tuple2<Long, Long>, String>> tupleDs = env.fromCollection(emptyNestedTupleData, nestedTupleTypeInfo);

	tupleDs.join(tupleDs).where(0).equalTo(0)
			.projectFirst(2, 0)
			.projectSecond(1, 3)
			.output(new DiscardingOutputFormat<Tuple>());

	Plan plan = env.createProgramPlan();

	GenericDataSinkBase<?> sink = plan.getDataSinks().iterator().next();
	InnerJoinOperatorBase<?, ?, ?, ?> projectJoinOperator = ((InnerJoinOperatorBase<?, ?, ?, ?>) sink.getInput());

	DualInputSemanticProperties props = projectJoinOperator.getSemanticProperties();

	assertEquals(1, props.getForwardingTargetFields(0, 0).size());
	assertNotNull(props.getForwardingTargetFields(0, 1));
	assertNotNull(props.getForwardingTargetFields(0, 2));
	assertNotNull(props.getForwardingTargetFields(0, 3));
	assertEquals(1, props.getForwardingTargetFields(0, 4).size());
	assertEquals(1, props.getForwardingTargetFields(0, 5).size());
	assertNotNull(props.getForwardingTargetFields(0, 6));
	assertEquals(0, props.getForwardingTargetFields(0, 1).size());
	assertEquals(0, props.getForwardingTargetFields(0, 2).size());
	assertEquals(0, props.getForwardingTargetFields(0, 3).size());
	assertEquals(0, props.getForwardingTargetFields(0, 6).size());

	assertNotNull(props.getForwardingTargetFields(1, 0));
	assertEquals(1, props.getForwardingTargetFields(1, 1).size());
	assertEquals(1, props.getForwardingTargetFields(1, 2).size());
	assertEquals(1, props.getForwardingTargetFields(1, 3).size());
	assertNotNull(props.getForwardingTargetFields(1, 4));
	assertNotNull(props.getForwardingTargetFields(1, 5));
	assertEquals(1, props.getForwardingTargetFields(1, 6).size());
	assertEquals(0, props.getForwardingTargetFields(1, 0).size());
	assertEquals(0, props.getForwardingTargetFields(1, 4).size());
	assertEquals(0, props.getForwardingTargetFields(1, 5).size());

	assertTrue(props.getForwardingTargetFields(0, 4).contains(0));
	assertTrue(props.getForwardingTargetFields(0, 5).contains(1));
	assertTrue(props.getForwardingTargetFields(0, 0).contains(2));
	assertTrue(props.getForwardingTargetFields(1, 1).contains(3));
	assertTrue(props.getForwardingTargetFields(1, 2).contains(4));
	assertTrue(props.getForwardingTargetFields(1, 3).contains(5));
	assertTrue(props.getForwardingTargetFields(1, 6).contains(6));
}
 
Example #15
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"));
}
 
Example #16
Source File: JoinNode.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the contract object for this match node.
 * 
 * @return The contract.
 */
@Override
public InnerJoinOperatorBase<?, ?, ?, ?> getOperator() {
	return (InnerJoinOperatorBase<?, ?, ?, ?>) super.getOperator();
}
 
Example #17
Source File: JoinNode.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the contract object for this match node.
 * 
 * @return The contract.
 */
@Override
public InnerJoinOperatorBase<?, ?, ?, ?> getOperator() {
	return (InnerJoinOperatorBase<?, ?, ?, ?>) super.getOperator();
}
 
Example #18
Source File: JoinNode.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the contract object for this match node.
 * 
 * @return The contract.
 */
@Override
public InnerJoinOperatorBase<?, ?, ?, ?> getOperator() {
	return (InnerJoinOperatorBase<?, ?, ?, ?>) super.getOperator();
}