Java Code Examples for org.apache.flink.api.common.operators.SingleInputSemanticProperties#addReadFields()

The following examples show how to use org.apache.flink.api.common.operators.SingleInputSemanticProperties#addReadFields() . 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: GroupCombineNode.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {

	// Local properties for GroupCombine may only be preserved on key fields.
	SingleInputSemanticProperties origProps =
			((SingleInputOperator<?,?,?>) getOperator()).getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	// only add forward field information for key fields
	if(this.keys != null) {
		for (int f : this.keys) {
			FieldSet targets = origProps.getForwardingTargetFields(0, f);
			for (int t : targets) {
				filteredProps.addForwardedField(f, t);
			}
		}
	}
	return filteredProps;
}
 
Example 2
Source File: GroupReduceNode.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
	// Local properties for GroupReduce may only be preserved on key fields.
	SingleInputSemanticProperties origProps = getOperator().getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	// only add forward field information for key fields
	if(this.keys != null) {
		for (int f : this.keys) {
			FieldSet targets = origProps.getForwardingTargetFields(0, f);
			for (int t : targets) {
				filteredProps.addForwardedField(f, t);
			}
		}
	}
	return filteredProps;
}
 
Example 3
Source File: SemanticPropUtil.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties.
 *
 * @param props The SemanticProperties to which the offset is added.
 * @param numInputFields The original number of fields of the input.
 * @param offset The offset that is added to each input field index.
 * @return New SemanticProperties with added offset.
 */
public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props,
																	int numInputFields, int offset) {

	SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties();
	if (props.getReadFields(0) != null) {
		FieldSet offsetReadFields = new FieldSet();
		for (int r : props.getReadFields(0)) {
			offsetReadFields = offsetReadFields.addField(r + offset);
		}
		offsetProps.addReadFields(offsetReadFields);
	}
	for (int s = 0; s < numInputFields; s++) {
		FieldSet targetFields = props.getForwardingTargetFields(0, s);
		for (int t : targetFields) {
			offsetProps.addForwardedField(s + offset, t);
		}
	}
	return offsetProps;
}
 
Example 4
Source File: GroupReduceNode.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
	// Local properties for GroupReduce may only be preserved on key fields.
	SingleInputSemanticProperties origProps = getOperator().getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	// only add forward field information for key fields
	if(this.keys != null) {
		for (int f : this.keys) {
			FieldSet targets = origProps.getForwardingTargetFields(0, f);
			for (int t : targets) {
				filteredProps.addForwardedField(f, t);
			}
		}
	}
	return filteredProps;
}
 
Example 5
Source File: SemanticPropUtil.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties.
 *
 * @param props The SemanticProperties to which the offset is added.
 * @param numInputFields The original number of fields of the input.
 * @param offset The offset that is added to each input field index.
 * @return New SemanticProperties with added offset.
 */
public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props,
																	int numInputFields, int offset) {

	SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties();
	if (props.getReadFields(0) != null) {
		FieldSet offsetReadFields = new FieldSet();
		for (int r : props.getReadFields(0)) {
			offsetReadFields = offsetReadFields.addField(r + offset);
		}
		offsetProps.addReadFields(offsetReadFields);
	}
	for (int s = 0; s < numInputFields; s++) {
		FieldSet targetFields = props.getForwardingTargetFields(0, s);
		for (int t : targetFields) {
			offsetProps.addForwardedField(s + offset, t);
		}
	}
	return offsetProps;
}
 
Example 6
Source File: GroupCombineNode.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {

	// Local properties for GroupCombine may only be preserved on key fields.
	SingleInputSemanticProperties origProps =
			((SingleInputOperator<?,?,?>) getOperator()).getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	// only add forward field information for key fields
	if(this.keys != null) {
		for (int f : this.keys) {
			FieldSet targets = origProps.getForwardingTargetFields(0, f);
			for (int t : targets) {
				filteredProps.addForwardedField(f, t);
			}
		}
	}
	return filteredProps;
}
 
Example 7
Source File: GroupReduceNode.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {
	// Local properties for GroupReduce may only be preserved on key fields.
	SingleInputSemanticProperties origProps = getOperator().getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	// only add forward field information for key fields
	if(this.keys != null) {
		for (int f : this.keys) {
			FieldSet targets = origProps.getForwardingTargetFields(0, f);
			for (int t : targets) {
				filteredProps.addForwardedField(f, t);
			}
		}
	}
	return filteredProps;
}
 
Example 8
Source File: SemanticPropUtil.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties.
 *
 * @param props The SemanticProperties to which the offset is added.
 * @param numInputFields The original number of fields of the input.
 * @param offset The offset that is added to each input field index.
 * @return New SemanticProperties with added offset.
 */
public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props,
																	int numInputFields, int offset) {

	SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties();
	if (props.getReadFields(0) != null) {
		FieldSet offsetReadFields = new FieldSet();
		for (int r : props.getReadFields(0)) {
			offsetReadFields = offsetReadFields.addField(r + offset);
		}
		offsetProps.addReadFields(offsetReadFields);
	}
	for (int s = 0; s < numInputFields; s++) {
		FieldSet targetFields = props.getForwardingTargetFields(0, s);
		for (int t : targetFields) {
			offsetProps.addForwardedField(s + offset, t);
		}
	}
	return offsetProps;
}
 
Example 9
Source File: GroupReduceNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupReduceOperatorBase<?,?,?> op = mock(GroupReduceOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupReduceNode node = new GroupReduceNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 10
Source File: GroupCombineNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupCombineOperatorBase<?,?,?> op = mock(GroupCombineOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupCombineNode node = new GroupCombineNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 11
Source File: MapPartitionNode.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {

	// Local properties for MapPartition may not be preserved.
	SingleInputSemanticProperties origProps =
			((SingleInputOperator<?,?,?>) getOperator()).getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	return filteredProps;
}
 
Example 12
Source File: MapPartitionNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	MapPartitionOperatorBase<?,?,?> op = mock(MapPartitionOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{});

	MapPartitionNode node = new MapPartitionNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) < 0);
	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 13
Source File: MapPartitionNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	MapPartitionOperatorBase<?,?,?> op = mock(MapPartitionOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{});

	MapPartitionNode node = new MapPartitionNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) < 0);
	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 14
Source File: GroupReduceNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupReduceOperatorBase<?,?,?> op = mock(GroupReduceOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupReduceNode node = new GroupReduceNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 15
Source File: GroupCombineNodeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupCombineOperatorBase<?,?,?> op = mock(GroupCombineOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupCombineNode node = new GroupCombineNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 16
Source File: MapPartitionNode.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {

	// Local properties for MapPartition may not be preserved.
	SingleInputSemanticProperties origProps =
			((SingleInputOperator<?,?,?>) getOperator()).getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	return filteredProps;
}
 
Example 17
Source File: MapPartitionNodeTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	MapPartitionOperatorBase<?,?,?> op = mock(MapPartitionOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{});

	MapPartitionNode node = new MapPartitionNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) < 0);
	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 18
Source File: GroupReduceNodeTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupReduceOperatorBase<?,?,?> op = mock(GroupReduceOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupReduceNode node = new GroupReduceNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 19
Source File: GroupCombineNodeTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSemanticProperties() {

	SingleInputSemanticProperties origProps = new SingleInputSemanticProperties();
	origProps.addForwardedField(0, 1);
	origProps.addForwardedField(2, 2);
	origProps.addForwardedField(3, 4);
	origProps.addForwardedField(6, 0);
	origProps.addReadFields(new FieldSet(0, 2, 4, 7));

	GroupCombineOperatorBase<?,?,?> op = mock(GroupCombineOperatorBase.class);
	when(op.getSemanticProperties()).thenReturn(origProps);
	when(op.getKeyColumns(0)).thenReturn(new int[]{3,2});
	when(op.getParameters()).thenReturn(new Configuration());

	GroupCombineNode node = new GroupCombineNode(op);

	SemanticProperties filteredProps = node.getSemanticPropertiesForLocalPropertyFiltering();

	assertTrue(filteredProps.getForwardingTargetFields(0, 0).size() == 0);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 2).contains(2));
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).size() == 1);
	assertTrue(filteredProps.getForwardingTargetFields(0, 3).contains(4));
	assertTrue(filteredProps.getForwardingTargetFields(0, 6).size() == 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 1) < 0);
	assertTrue(filteredProps.getForwardingSourceField(0, 2) == 2);
	assertTrue(filteredProps.getForwardingSourceField(0, 4) == 3);
	assertTrue(filteredProps.getForwardingSourceField(0, 0) < 0);

	assertTrue(filteredProps.getReadFields(0).size() == 4);
	assertTrue(filteredProps.getReadFields(0).contains(0));
	assertTrue(filteredProps.getReadFields(0).contains(2));
	assertTrue(filteredProps.getReadFields(0).contains(4));
	assertTrue(filteredProps.getReadFields(0).contains(7));

}
 
Example 20
Source File: MapPartitionNode.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected SemanticProperties getSemanticPropertiesForLocalPropertyFiltering() {

	// Local properties for MapPartition may not be preserved.
	SingleInputSemanticProperties origProps =
			((SingleInputOperator<?,?,?>) getOperator()).getSemanticProperties();
	SingleInputSemanticProperties filteredProps = new SingleInputSemanticProperties();
	FieldSet readSet = origProps.getReadFields(0);
	if(readSet != null) {
		filteredProps.addReadFields(readSet);
	}

	return filteredProps;
}