Java Code Examples for org.apache.flink.api.java.tuple.Tuple8

The following examples show how to use org.apache.flink.api.java.tuple.Tuple8. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: UdfAnalyzerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> map(
		Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> value)
				throws Exception {
	Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> tuple =
		new Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>();
	// non-input content
	if (tuple.f0 == null) {
		tuple.setField(123456, 0);
	} else {
		tuple.setField(value.f0, 0);
	}
	// forwarding
	tuple.setField(value.f2, 3);
	tuple.setField(value.f3, 7);
	// TODO multiple mapping is unsupported yet
	//tuple.setField(value.f1, 3);
	return tuple;
}
 
Example 2
Source Project: Flink-CEPplus   Source File: CsvReaderITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testValueTypes() throws Exception {
	final String inputData = "ABC,true,1,2,3,4,5.0,6.0\nBCD,false,1,2,3,4,5.0,6.0";
	final String dataPath = createInputData(inputData);
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> data =
			env.readCsvFile(dataPath).types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	List<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> result = data.collect();

	expected = inputData;
	compareResultAsTuples(result, expected);
}
 
Example 3
Source Project: Flink-CEPplus   Source File: UdfAnalyzerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Tuple8<Boolean, Character, Byte, Short, Integer, Long, Float, Double> map(
		Tuple8<Boolean, Character, Byte, Short, Integer, Long, Float, Double> value) throws Exception {
	boolean f0 = value.f0;
	char f1 = value.f1;
	byte f2 = value.f2;
	short f3 = value.f3;
	int f4 = value.f4;
	long f5 = value.f5;
	float f6 = value.f6;
	double f7 = value.f7;
	return new Tuple8<Boolean, Character, Byte, Short, Integer, Long, Float, Double>(
			f0, f1, f2, f3, f4, f5, f6, f7);
}
 
Example 4
Source Project: Flink-CEPplus   Source File: CSVReaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithValueType() throws Exception {
	CsvReader reader = getCsvReader();
	DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items =
			reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	TypeInformation<?> info = items.getType();

	Assert.assertEquals(true, info.isTupleType());
	Assert.assertEquals(Tuple8.class, info.getTypeClass());
}
 
Example 5
Source Project: flink   Source File: CsvReaderITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testValueTypes() throws Exception {
	final String inputData = "ABC,true,1,2,3,4,5.0,6.0\nBCD,false,1,2,3,4,5.0,6.0";
	final String dataPath = createInputData(inputData);
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> data =
			env.readCsvFile(dataPath).types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	List<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> result = data.collect();

	expected = inputData;
	compareResultAsTuples(result, expected);
}
 
Example 6
Source Project: flink   Source File: CSVReaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithValueType() throws Exception {
	CsvReader reader = getCsvReader();
	DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items =
			reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	TypeInformation<?> info = items.getType();

	Assert.assertEquals(true, info.isTupleType());
	Assert.assertEquals(Tuple8.class, info.getTypeClass());
}
 
Example 7
public static Tuple8<Integer, String, String[], Tuple2<Integer, String>[], Integer, Integer, Integer, Object> createTuple(
		int id,
		String name,
		String[] operationNames,
		Tuple2<Integer, String>[] operations,
		int otherId1,
		int otherId2,
		int otherId3,
		Object someObject) {
	return Tuple8.of(id, name, operationNames, operations, otherId1, otherId2, otherId3, someObject);
}
 
Example 8
Source Project: flink   Source File: CsvReaderITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testValueTypes() throws Exception {
	final String inputData = "ABC,true,1,2,3,4,5.0,6.0\nBCD,false,1,2,3,4,5.0,6.0";
	final String dataPath = createInputData(inputData);
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> data =
			env.readCsvFile(dataPath).types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	List<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> result = data.collect();

	expected = inputData;
	compareResultAsTuples(result, expected);
}
 
Example 9
Source Project: flink   Source File: CSVReaderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithValueType() throws Exception {
	CsvReader reader = getCsvReader();
	DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items =
			reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class);
	TypeInformation<?> info = items.getType();

	Assert.assertEquals(true, info.isTupleType());
	Assert.assertEquals(Tuple8.class, info.getTypeClass());
}
 
Example 10
Source Project: Flink-CEPplus   Source File: DataSetUtilsITCase.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testSummarize() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	List<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> data = new ArrayList<>();
	data.add(new Tuple8<>((short) 1, 1, 100L, 0.1f, 1.012376, "hello", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 2, 2, 1000L, 0.2f, 2.003453, "hello", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 4, 10, 10000L, 0.2f, 75.00005, "null", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 10, 4, 100L, 0.9f, 79.5, "", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 5, 5, 1000L, 0.2f, 10.0000001, "a", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 6, 6, 10L, 0.1f, 0.0000000000023, "", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 7, 7, 1L, 0.2f, Double.POSITIVE_INFINITY, "abcdefghijklmnop", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 8, 8, -100L, 0.001f, Double.NaN, "abcdefghi", true, new DoubleValue(100.0)));

	Collections.shuffle(data);

	DataSet<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> ds = env.fromCollection(data);

	// call method under test
	Tuple results = DataSetUtils.summarize(ds);

	Assert.assertEquals(8, results.getArity());

	NumericColumnSummary<Short> col0Summary = results.getField(0);
	Assert.assertEquals(8, col0Summary.getNonMissingCount());
	Assert.assertEquals(1, col0Summary.getMin().shortValue());
	Assert.assertEquals(10, col0Summary.getMax().shortValue());
	Assert.assertEquals(5.375, col0Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Integer> col1Summary = results.getField(1);
	Assert.assertEquals(1, col1Summary.getMin().intValue());
	Assert.assertEquals(10, col1Summary.getMax().intValue());
	Assert.assertEquals(5.375, col1Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Long> col2Summary = results.getField(2);
	Assert.assertEquals(-100L, col2Summary.getMin().longValue());
	Assert.assertEquals(10000L, col2Summary.getMax().longValue());

	NumericColumnSummary<Float> col3Summary = results.getField(3);
	Assert.assertEquals(8, col3Summary.getTotalCount());
	Assert.assertEquals(0.001000, col3Summary.getMin().doubleValue(), 0.0000001);
	Assert.assertEquals(0.89999999, col3Summary.getMax().doubleValue(), 0.0000001);
	Assert.assertEquals(0.2376249988883501, col3Summary.getMean().doubleValue(), 0.000000000001);
	Assert.assertEquals(0.0768965488108089, col3Summary.getVariance().doubleValue(), 0.00000001);
	Assert.assertEquals(0.27730226975415995, col3Summary.getStandardDeviation().doubleValue(), 0.000000000001);

	NumericColumnSummary<Double> col4Summary = results.getField(4);
	Assert.assertEquals(6, col4Summary.getNonMissingCount());
	Assert.assertEquals(2, col4Summary.getMissingCount());
	Assert.assertEquals(0.0000000000023, col4Summary.getMin().doubleValue(), 0.0);
	Assert.assertEquals(79.5, col4Summary.getMax().doubleValue(), 0.000000000001);

	StringColumnSummary col5Summary = results.getField(5);
	Assert.assertEquals(8, col5Summary.getTotalCount());
	Assert.assertEquals(0, col5Summary.getNullCount());
	Assert.assertEquals(8, col5Summary.getNonNullCount());
	Assert.assertEquals(2, col5Summary.getEmptyCount());
	Assert.assertEquals(0, col5Summary.getMinLength().intValue());
	Assert.assertEquals(16, col5Summary.getMaxLength().intValue());
	Assert.assertEquals(5.0, col5Summary.getMeanLength().doubleValue(), 0.0001);

	BooleanColumnSummary col6Summary = results.getField(6);
	Assert.assertEquals(8, col6Summary.getTotalCount());
	Assert.assertEquals(2, col6Summary.getFalseCount());
	Assert.assertEquals(6, col6Summary.getTrueCount());
	Assert.assertEquals(0, col6Summary.getNullCount());

	NumericColumnSummary<Double> col7Summary = results.getField(7);
	Assert.assertEquals(100.0, col7Summary.getMax().doubleValue(), 0.00001);
	Assert.assertEquals(50.0, col7Summary.getMin().doubleValue(), 0.00001);
}
 
Example 11
Source Project: Flink-CEPplus   Source File: UdfAnalyzerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testForwardWithTuplesGetSetFieldMethods2() {
	compareAnalyzerResultWithAnnotationsSingleInput(MapFunction.class, Map27.class,
		TypeInformation.of(new TypeHint<Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>>(){}),
		TypeInformation.of(new TypeHint<Tuple8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer>>(){}));
}
 
Example 12
Source Project: Flink-CEPplus   Source File: UdfAnalyzerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testForwardWithUnboxingAndBoxing() {
	compareAnalyzerResultWithAnnotationsSingleInput(MapFunction.class, Map32.class,
		TypeInformation.of(new TypeHint<Tuple8<Boolean, Character, Byte, Short, Integer, Long, Float, Double>>(){}),
		TypeInformation.of(new TypeHint<Tuple8<Boolean, Character, Byte, Short, Integer, Long, Float, Double>>(){}));
}
 
Example 13
Source Project: Flink-CEPplus   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
public Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7){
	tuples.add(new Tuple8<>(value0, value1, value2, value3, value4, value5, value6, value7));
	return this;
}
 
Example 14
Source Project: Flink-CEPplus   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>[] build(){
	return tuples.toArray(new Tuple8[tuples.size()]);
}
 
Example 15
Source Project: flink   Source File: DataSetUtilsITCase.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testSummarize() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	List<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> data = new ArrayList<>();
	data.add(new Tuple8<>((short) 1, 1, 100L, 0.1f, 1.012376, "hello", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 2, 2, 1000L, 0.2f, 2.003453, "hello", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 4, 10, 10000L, 0.2f, 75.00005, "null", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 10, 4, 100L, 0.9f, 79.5, "", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 5, 5, 1000L, 0.2f, 10.0000001, "a", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 6, 6, 10L, 0.1f, 0.0000000000023, "", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 7, 7, 1L, 0.2f, Double.POSITIVE_INFINITY, "abcdefghijklmnop", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 8, 8, -100L, 0.001f, Double.NaN, "abcdefghi", true, new DoubleValue(100.0)));

	Collections.shuffle(data);

	DataSet<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> ds = env.fromCollection(data);

	// call method under test
	Tuple results = DataSetUtils.summarize(ds);

	Assert.assertEquals(8, results.getArity());

	NumericColumnSummary<Short> col0Summary = results.getField(0);
	Assert.assertEquals(8, col0Summary.getNonMissingCount());
	Assert.assertEquals(1, col0Summary.getMin().shortValue());
	Assert.assertEquals(10, col0Summary.getMax().shortValue());
	Assert.assertEquals(5.375, col0Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Integer> col1Summary = results.getField(1);
	Assert.assertEquals(1, col1Summary.getMin().intValue());
	Assert.assertEquals(10, col1Summary.getMax().intValue());
	Assert.assertEquals(5.375, col1Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Long> col2Summary = results.getField(2);
	Assert.assertEquals(-100L, col2Summary.getMin().longValue());
	Assert.assertEquals(10000L, col2Summary.getMax().longValue());

	NumericColumnSummary<Float> col3Summary = results.getField(3);
	Assert.assertEquals(8, col3Summary.getTotalCount());
	Assert.assertEquals(0.001000, col3Summary.getMin().doubleValue(), 0.0000001);
	Assert.assertEquals(0.89999999, col3Summary.getMax().doubleValue(), 0.0000001);
	Assert.assertEquals(0.2376249988883501, col3Summary.getMean().doubleValue(), 0.000000000001);
	Assert.assertEquals(0.0768965488108089, col3Summary.getVariance().doubleValue(), 0.00000001);
	Assert.assertEquals(0.27730226975415995, col3Summary.getStandardDeviation().doubleValue(), 0.000000000001);

	NumericColumnSummary<Double> col4Summary = results.getField(4);
	Assert.assertEquals(6, col4Summary.getNonMissingCount());
	Assert.assertEquals(2, col4Summary.getMissingCount());
	Assert.assertEquals(0.0000000000023, col4Summary.getMin().doubleValue(), 0.0);
	Assert.assertEquals(79.5, col4Summary.getMax().doubleValue(), 0.000000000001);

	StringColumnSummary col5Summary = results.getField(5);
	Assert.assertEquals(8, col5Summary.getTotalCount());
	Assert.assertEquals(0, col5Summary.getNullCount());
	Assert.assertEquals(8, col5Summary.getNonNullCount());
	Assert.assertEquals(2, col5Summary.getEmptyCount());
	Assert.assertEquals(0, col5Summary.getMinLength().intValue());
	Assert.assertEquals(16, col5Summary.getMaxLength().intValue());
	Assert.assertEquals(5.0, col5Summary.getMeanLength().doubleValue(), 0.0001);

	BooleanColumnSummary col6Summary = results.getField(6);
	Assert.assertEquals(8, col6Summary.getTotalCount());
	Assert.assertEquals(2, col6Summary.getFalseCount());
	Assert.assertEquals(6, col6Summary.getTrueCount());
	Assert.assertEquals(0, col6Summary.getNullCount());

	NumericColumnSummary<Double> col7Summary = results.getField(7);
	Assert.assertEquals(100.0, col7Summary.getMax().doubleValue(), 0.00001);
	Assert.assertEquals(50.0, col7Summary.getMin().doubleValue(), 0.00001);
}
 
Example 16
Source Project: flink   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
public Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7){
	tuples.add(new Tuple8<>(value0, value1, value2, value3, value4, value5, value6, value7));
	return this;
}
 
Example 17
Source Project: flink   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>[] build(){
	return tuples.toArray(new Tuple8[tuples.size()]);
}
 
Example 18
@Override
protected Tuple8<Integer, String, String[], Tuple2<Integer, String>[], Integer, Integer, Integer, Object> getElement(int keyId) {
	template.setField(keyId, 0);
	return template;
}
 
Example 19
Source Project: flink-siddhi   Source File: SiddhiTupleFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Convert object array to type of Tuple{N} where N is between 0 to 25.
 *
 * @throws IllegalArgumentException if rows's length > 25
 */
public static <T extends Tuple> T newTuple(Object[] row) {
    Preconditions.checkNotNull(row, "Tuple row is null");
    switch (row.length) {
        case 0:
            return setTupleValue(new Tuple0(), row);
        case 1:
            return setTupleValue(new Tuple1(), row);
        case 2:
            return setTupleValue(new Tuple2(), row);
        case 3:
            return setTupleValue(new Tuple3(), row);
        case 4:
            return setTupleValue(new Tuple4(), row);
        case 5:
            return setTupleValue(new Tuple5(), row);
        case 6:
            return setTupleValue(new Tuple6(), row);
        case 7:
            return setTupleValue(new Tuple7(), row);
        case 8:
            return setTupleValue(new Tuple8(), row);
        case 9:
            return setTupleValue(new Tuple9(), row);
        case 10:
            return setTupleValue(new Tuple10(), row);
        case 11:
            return setTupleValue(new Tuple11(), row);
        case 12:
            return setTupleValue(new Tuple12(), row);
        case 13:
            return setTupleValue(new Tuple13(), row);
        case 14:
            return setTupleValue(new Tuple14(), row);
        case 15:
            return setTupleValue(new Tuple15(), row);
        case 16:
            return setTupleValue(new Tuple16(), row);
        case 17:
            return setTupleValue(new Tuple17(), row);
        case 18:
            return setTupleValue(new Tuple18(), row);
        case 19:
            return setTupleValue(new Tuple19(), row);
        case 20:
            return setTupleValue(new Tuple20(), row);
        case 21:
            return setTupleValue(new Tuple21(), row);
        case 22:
            return setTupleValue(new Tuple22(), row);
        case 23:
            return setTupleValue(new Tuple23(), row);
        case 24:
            return setTupleValue(new Tuple24(), row);
        case 25:
            return setTupleValue(new Tuple25(), row);
        default:
            throw new IllegalArgumentException("Too long row: " + row.length + ", unable to convert to Tuple");
    }
}
 
Example 20
Source Project: bahir-flink   Source File: SiddhiTupleFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Convert object array to type of Tuple{N} where N is between 0 to 25.
 *
 * @throws IllegalArgumentException if rows's length > 25
 */
public static <T extends Tuple> T newTuple(Object[] row) {
    Preconditions.checkNotNull(row, "Tuple row is null");
    switch (row.length) {
        case 0:
            return setTupleValue(new Tuple0(), row);
        case 1:
            return setTupleValue(new Tuple1<>(), row);
        case 2:
            return setTupleValue(new Tuple2<>(), row);
        case 3:
            return setTupleValue(new Tuple3<>(), row);
        case 4:
            return setTupleValue(new Tuple4<>(), row);
        case 5:
            return setTupleValue(new Tuple5<>(), row);
        case 6:
            return setTupleValue(new Tuple6<>(), row);
        case 7:
            return setTupleValue(new Tuple7<>(), row);
        case 8:
            return setTupleValue(new Tuple8<>(), row);
        case 9:
            return setTupleValue(new Tuple9<>(), row);
        case 10:
            return setTupleValue(new Tuple10<>(), row);
        case 11:
            return setTupleValue(new Tuple11<>(), row);
        case 12:
            return setTupleValue(new Tuple12<>(), row);
        case 13:
            return setTupleValue(new Tuple13<>(), row);
        case 14:
            return setTupleValue(new Tuple14<>(), row);
        case 15:
            return setTupleValue(new Tuple15<>(), row);
        case 16:
            return setTupleValue(new Tuple16<>(), row);
        case 17:
            return setTupleValue(new Tuple17<>(), row);
        case 18:
            return setTupleValue(new Tuple18<>(), row);
        case 19:
            return setTupleValue(new Tuple19<>(), row);
        case 20:
            return setTupleValue(new Tuple20<>(), row);
        case 21:
            return setTupleValue(new Tuple21<>(), row);
        case 22:
            return setTupleValue(new Tuple22<>(), row);
        case 23:
            return setTupleValue(new Tuple23<>(), row);
        case 24:
            return setTupleValue(new Tuple24<>(), row);
        case 25:
            return setTupleValue(new Tuple25<>(), row);
        default:
            throw new IllegalArgumentException("Too long row: " + row.length + ", unable to convert to Tuple");
    }
}
 
Example 21
Source Project: flink   Source File: DataSetUtilsITCase.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testSummarize() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	List<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> data = new ArrayList<>();
	data.add(new Tuple8<>((short) 1, 1, 100L, 0.1f, 1.012376, "hello", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 2, 2, 1000L, 0.2f, 2.003453, "hello", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 4, 10, 10000L, 0.2f, 75.00005, "null", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 10, 4, 100L, 0.9f, 79.5, "", true, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 5, 5, 1000L, 0.2f, 10.0000001, "a", false, new DoubleValue(50.0)));
	data.add(new Tuple8<>((short) 6, 6, 10L, 0.1f, 0.0000000000023, "", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 7, 7, 1L, 0.2f, Double.POSITIVE_INFINITY, "abcdefghijklmnop", true, new DoubleValue(100.0)));
	data.add(new Tuple8<>((short) 8, 8, -100L, 0.001f, Double.NaN, "abcdefghi", true, new DoubleValue(100.0)));

	Collections.shuffle(data);

	DataSet<Tuple8<Short, Integer, Long, Float, Double, String, Boolean, DoubleValue>> ds = env.fromCollection(data);

	// call method under test
	Tuple results = DataSetUtils.summarize(ds);

	Assert.assertEquals(8, results.getArity());

	NumericColumnSummary<Short> col0Summary = results.getField(0);
	Assert.assertEquals(8, col0Summary.getNonMissingCount());
	Assert.assertEquals(1, col0Summary.getMin().shortValue());
	Assert.assertEquals(10, col0Summary.getMax().shortValue());
	Assert.assertEquals(5.375, col0Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Integer> col1Summary = results.getField(1);
	Assert.assertEquals(1, col1Summary.getMin().intValue());
	Assert.assertEquals(10, col1Summary.getMax().intValue());
	Assert.assertEquals(5.375, col1Summary.getMean().doubleValue(), 0.0);

	NumericColumnSummary<Long> col2Summary = results.getField(2);
	Assert.assertEquals(-100L, col2Summary.getMin().longValue());
	Assert.assertEquals(10000L, col2Summary.getMax().longValue());

	NumericColumnSummary<Float> col3Summary = results.getField(3);
	Assert.assertEquals(8, col3Summary.getTotalCount());
	Assert.assertEquals(0.001000, col3Summary.getMin().doubleValue(), 0.0000001);
	Assert.assertEquals(0.89999999, col3Summary.getMax().doubleValue(), 0.0000001);
	Assert.assertEquals(0.2376249988883501, col3Summary.getMean().doubleValue(), 0.000000000001);
	Assert.assertEquals(0.0768965488108089, col3Summary.getVariance().doubleValue(), 0.00000001);
	Assert.assertEquals(0.27730226975415995, col3Summary.getStandardDeviation().doubleValue(), 0.000000000001);

	NumericColumnSummary<Double> col4Summary = results.getField(4);
	Assert.assertEquals(6, col4Summary.getNonMissingCount());
	Assert.assertEquals(2, col4Summary.getMissingCount());
	Assert.assertEquals(0.0000000000023, col4Summary.getMin().doubleValue(), 0.0);
	Assert.assertEquals(79.5, col4Summary.getMax().doubleValue(), 0.000000000001);

	StringColumnSummary col5Summary = results.getField(5);
	Assert.assertEquals(8, col5Summary.getTotalCount());
	Assert.assertEquals(0, col5Summary.getNullCount());
	Assert.assertEquals(8, col5Summary.getNonNullCount());
	Assert.assertEquals(2, col5Summary.getEmptyCount());
	Assert.assertEquals(0, col5Summary.getMinLength().intValue());
	Assert.assertEquals(16, col5Summary.getMaxLength().intValue());
	Assert.assertEquals(5.0, col5Summary.getMeanLength().doubleValue(), 0.0001);

	BooleanColumnSummary col6Summary = results.getField(6);
	Assert.assertEquals(8, col6Summary.getTotalCount());
	Assert.assertEquals(2, col6Summary.getFalseCount());
	Assert.assertEquals(6, col6Summary.getTrueCount());
	Assert.assertEquals(0, col6Summary.getNullCount());

	NumericColumnSummary<Double> col7Summary = results.getField(7);
	Assert.assertEquals(100.0, col7Summary.getMax().doubleValue(), 0.00001);
	Assert.assertEquals(50.0, col7Summary.getMin().doubleValue(), 0.00001);
}
 
Example 22
Source Project: flink   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
public Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7){
	tuples.add(new Tuple8<>(value0, value1, value2, value3, value4, value5, value6, value7));
	return this;
}
 
Example 23
Source Project: flink   Source File: Tuple8Builder.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>[] build(){
	return tuples.toArray(new Tuple8[tuples.size()]);
}
 
Example 24
Source Project: Flink-CEPplus   Source File: JoinOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a pair of joined elements to a {@link Tuple} with the previously selected fields.
 * Requires the classes of the fields of the resulting tuples.
 *
 * @return The projected data set.
 *
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectJoin<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectJoin<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);
}
 
Example 25
Source Project: Flink-CEPplus   Source File: ProjectOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a {@link Tuple} {@link DataSet} to the previously selected fields.
 *
 * @return The projected DataSet.
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectOperator<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectOperator<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds, this.fieldIndexes, tType);
}
 
Example 26
Source Project: Flink-CEPplus   Source File: CrossOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a pair of crossed elements to a {@link Tuple} with the previously selected fields.
 *
 * @return The projected data set.
 *
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectCross<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectCross<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);
}
 
Example 27
Source Project: Flink-CEPplus   Source File: StreamProjection.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
 *
 * @return The projected DataStream.
 * @see Tuple
 * @see DataStream
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> SingleOutputStreamOperator<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return dataStream.transform("Projection", tType, new StreamProject<IN, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fieldIndexes, tType.createSerializer(dataStream.getExecutionConfig())));
}
 
Example 28
Source Project: flink   Source File: JoinOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a pair of joined elements to a {@link Tuple} with the previously selected fields.
 * Requires the classes of the fields of the resulting tuples.
 *
 * @return The projected data set.
 *
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectJoin<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectJoin<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);
}
 
Example 29
Source Project: flink   Source File: ProjectOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a {@link Tuple} {@link DataSet} to the previously selected fields.
 *
 * @return The projected DataSet.
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectOperator<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectOperator<T, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds, this.fieldIndexes, tType);
}
 
Example 30
Source Project: flink   Source File: CrossOperator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Projects a pair of crossed elements to a {@link Tuple} with the previously selected fields.
 *
 * @return The projected data set.
 *
 * @see Tuple
 * @see DataSet
 */
public <T0, T1, T2, T3, T4, T5, T6, T7> ProjectCross<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> projectTuple8() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tType = new TupleTypeInfo<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(fTypes);

	return new ProjectCross<I1, I2, Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);
}