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

The following examples show how to use org.apache.flink.api.java.DataSet#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 6 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty dataset
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env
			.fromCollection(emptyTupleData, tupleTypeInfo);

	// should work
	try {
		tupleDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
Example 2
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty dataset
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env
			.fromCollection(emptyTupleData, tupleTypeInfo);

	// should work
	try {
		tupleDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
Example 3
Source File: MinByOperatorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test validates that no exceptions is thrown when an empty dataset
 * calls minBy().
 */
@Test
public void testMinByKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env
			.fromCollection(emptyTupleData, tupleTypeInfo);

	// should work
	try {
		tupleDs.minBy(4, 0, 1, 2, 3);
	} catch (Exception e) {
		Assert.fail();
	}
}
 
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 InvalidProgramException is thrown when minBy
 * is used on a custom data type.
 */
@Test(expected = InvalidProgramException.class)
public void testCustomKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	DataSet<CustomType> customDs = env.fromCollection(customTypeData);
	// should not work: groups on custom type
	customDs.minBy(0);
}
 
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 testOutOfTupleBoundsDataset1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(5);
}
 
Example 6
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 testOutOfTupleBoundsDataset2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(-1);
}
 
Example 7
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 testOutOfTupleBoundsDataset3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(1, 2, 3, 4, -1);
}
 
Example 8
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 testCustomKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	DataSet<CustomType> customDs = env.fromCollection(customTypeData);
	// should not work: groups on custom type
	customDs.minBy(0);
}
 
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 testOutOfTupleBoundsDataset1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(5);
}
 
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 testOutOfTupleBoundsDataset2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(-1);
}
 
Example 11
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 testOutOfTupleBoundsDataset3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.minBy(1, 2, 3, 4, -1);
}
 
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 testCustomKeyFieldsDataset() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	DataSet<CustomType> customDs = env.fromCollection(customTypeData);
	// should not work: groups on custom type
	customDs.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 testOutOfTupleBoundsDataset1() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.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 testOutOfTupleBoundsDataset2() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.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 testOutOfTupleBoundsDataset3() {

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// should not work, key out of tuple bounds
	tupleDs.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 testMinByRowTypeInfoKeyFieldsDataset() {

	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);
	DataSet tupleDs = env
			.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo);

	tupleDs.minBy(0);
}