Java Code Examples for org.apache.flink.api.java.operators.UnsortedGrouping#minBy()

The following examples show how to use org.apache.flink.api.java.operators.UnsortedGrouping#minBy() . 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: MinByOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty grouping
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should work
	try {
		groupDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
Example 2
Source File: MinByOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an InvalidProgramException is thrown when minBy
 * is used on a custom data type.
 */
@Test(expected = InvalidProgramException.class)
public void testCustomKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	this.customTypeData.add(new CustomType());

	UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0);
	// should not work: groups on custom type
	groupDs.minBy(0);
}
 
Example 3
Source File: MinByOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(5);
}
 
Example 4
Source File: MinByOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(-1);
}
 
Example 5
Source File: MinByOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(1, 2, 3, 4, -1);
}
 
Example 6
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty grouping
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should work
	try {
		groupDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
Example 7
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an InvalidProgramException is thrown when minBy
 * is used on a custom data type.
 */
@Test(expected = InvalidProgramException.class)
public void testCustomKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	this.customTypeData.add(new CustomType());

	UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0);
	// should not work: groups on custom type
	groupDs.minBy(0);
}
 
Example 8
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(5);
}
 
Example 9
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(-1);
}
 
Example 10
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(1, 2, 3, 4, -1);
}
 
Example 11
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty grouping
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should work
	try {
		groupDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
Example 12
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an InvalidProgramException is thrown when minBy
 * is used on a custom data type.
 */
@Test(expected = InvalidProgramException.class)
public void testCustomKeyFieldsGrouping() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	this.customTypeData.add(new CustomType());

	UnsortedGrouping<CustomType> groupDs = env.fromCollection(customTypeData).groupBy(0);
	// should not work: groups on custom type
	groupDs.minBy(0);
}
 
Example 13
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(5);
}
 
Example 14
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(-1);
}
 
Example 15
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test validates that an index which is out of bounds throws an
 * IndexOutOfBoundsException.
 */
@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfTupleBoundsGrouping3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	UnsortedGrouping<Tuple5<Integer, Long, String, Long, Integer>> groupDs = env.fromCollection(emptyTupleData, tupleTypeInfo).groupBy(0);

	// should not work, key out of tuple bounds
	groupDs.minBy(1, 2, 3, 4, -1);
}
 
Example 16
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Validates that no ClassCastException happens
 * should not fail e.g. like in FLINK-8255.
 */
@Test(expected = InvalidProgramException.class)
public void testMinByRowTypeInfoKeyFieldsForUnsortedGrouping() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	TypeInformation[] types = new TypeInformation[]{Types.INT, Types.INT};

	String[] fieldNames = new String[]{"id", "value"};
	RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames);

	UnsortedGrouping groupDs = env.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo).groupBy(0);

	groupDs.minBy(1);
}