org.apache.flink.api.java.tuple.Tuple9 Java Examples

The following examples show how to use org.apache.flink.api.java.tuple.Tuple9. 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: TypeExtractorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTupleWithPrimitiveArray() {
	RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>> function = new RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<int[], double[], long[], byte[], char[], float[], short[], boolean[], String[]> map(Integer value) throws Exception {
			return null;
		}
	};
	
	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.INT_TYPE_INFO);
	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, tti.getTypeAt(8));
}
 
Example #2
Source File: TypeExtractorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTupleWithPrimitiveArray() {
	RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>> function = new RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<int[], double[], long[], byte[], char[], float[], short[], boolean[], String[]> map(Integer value) throws Exception {
			return null;
		}
	};
	
	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.INT_TYPE_INFO);
	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, tti.getTypeAt(8));
}
 
Example #3
Source File: TypeExtractorTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTupleWithPrimitiveArray() {
	RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>> function = new RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<int[], double[], long[], byte[], char[], float[], short[], boolean[], String[]> map(Integer value) throws Exception {
			return null;
		}
	};
	
	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.INT_TYPE_INFO);
	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, tti.getTypeAt(8));
}
 
Example #4
Source File: Tuple9Builder.java    From flink with Apache License 2.0 4 votes vote down vote up
public Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8){
	tuples.add(new Tuple9<>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
	return this;
}
 
Example #5
Source File: SiddhiTupleFactory.java    From bahir-flink with 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 #6
Source File: SiddhiTupleFactory.java    From flink-siddhi with 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 #7
Source File: TypeExtractorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testTupleWithBasicTypes() throws Exception {
	// use getMapReturnTypes()
	RichMapFunction<?, ?> function = new RichMapFunction<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>, Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> map(
				Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> value) throws Exception {
			return null;
		}

	};

	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>(){}));

	Assert.assertTrue(ti.isTupleType());
	Assert.assertEquals(9, ti.getArity());
	Assert.assertTrue(ti instanceof TupleTypeInfo);
	List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
	((TupleTypeInfo) ti).getFlatFields("f3", 0, ffd);
	Assert.assertTrue(ffd.size() == 1);
	Assert.assertEquals(3, ffd.get(0).getPosition() );

	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(Tuple9.class, tti.getTypeClass());
	
	for (int i = 0; i < 9; i++) {
		Assert.assertTrue(tti.getTypeAt(i) instanceof BasicTypeInfo);
	}

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti.getTypeAt(8));

	// use getForObject()
	Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> t = new Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>(
			1, 1L, 1.0, 1.0F, false, "Hello World", 'w', (short) 1, (byte) 1);

	Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
	TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti2.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti2.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti2.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti2.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti2.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti2.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti2.getTypeAt(8));
	
	// test that getForClass does not work
	try {
		TypeExtractor.getForClass(Tuple9.class);
		Assert.fail("Exception expected here");
	} catch (InvalidTypesException e) {
		// that is correct
	}
}
 
Example #8
Source File: Tuple9Builder.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
	return tuples.toArray(new Tuple9[tuples.size()]);
}
 
Example #9
Source File: Tuple9Builder.java    From flink with Apache License 2.0 4 votes vote down vote up
public Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8){
	tuples.add(new Tuple9<>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
	return this;
}
 
Example #10
Source File: Tuple9Builder.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
	return tuples.toArray(new Tuple9[tuples.size()]);
}
 
Example #11
Source File: TypeExtractorTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testTupleWithBasicTypes() throws Exception {
	// use getMapReturnTypes()
	RichMapFunction<?, ?> function = new RichMapFunction<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>, Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> map(
				Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> value) throws Exception {
			return null;
		}

	};

	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>(){}));

	Assert.assertTrue(ti.isTupleType());
	Assert.assertEquals(9, ti.getArity());
	Assert.assertTrue(ti instanceof TupleTypeInfo);
	List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
	((TupleTypeInfo) ti).getFlatFields("f3", 0, ffd);
	Assert.assertTrue(ffd.size() == 1);
	Assert.assertEquals(3, ffd.get(0).getPosition() );

	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(Tuple9.class, tti.getTypeClass());
	
	for (int i = 0; i < 9; i++) {
		Assert.assertTrue(tti.getTypeAt(i) instanceof BasicTypeInfo);
	}

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti.getTypeAt(8));

	// use getForObject()
	Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> t = new Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>(
			1, 1L, 1.0, 1.0F, false, "Hello World", 'w', (short) 1, (byte) 1);

	Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
	TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti2.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti2.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti2.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti2.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti2.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti2.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti2.getTypeAt(8));
	
	// test that getForClass does not work
	try {
		TypeExtractor.getForClass(Tuple9.class);
		Assert.fail("Exception expected here");
	} catch (InvalidTypesException e) {
		// that is correct
	}
}
 
Example #12
Source File: TypeExtractorTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testTupleWithBasicTypes() throws Exception {
	// use getMapReturnTypes()
	RichMapFunction<?, ?> function = new RichMapFunction<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>, Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>() {
		private static final long serialVersionUID = 1L;

		@Override
		public Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> map(
				Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> value) throws Exception {
			return null;
		}

	};

	TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInformation.of(new TypeHint<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>(){}));

	Assert.assertTrue(ti.isTupleType());
	Assert.assertEquals(9, ti.getArity());
	Assert.assertTrue(ti instanceof TupleTypeInfo);
	List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
	((TupleTypeInfo) ti).getFlatFields("f3", 0, ffd);
	Assert.assertTrue(ffd.size() == 1);
	Assert.assertEquals(3, ffd.get(0).getPosition() );

	TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
	Assert.assertEquals(Tuple9.class, tti.getTypeClass());
	
	for (int i = 0; i < 9; i++) {
		Assert.assertTrue(tti.getTypeAt(i) instanceof BasicTypeInfo);
	}

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti.getTypeAt(8));

	// use getForObject()
	Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> t = new Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>(
			1, 1L, 1.0, 1.0F, false, "Hello World", 'w', (short) 1, (byte) 1);

	Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
	TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);

	Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
	Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti2.getTypeAt(1));
	Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti2.getTypeAt(2));
	Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(3));
	Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti2.getTypeAt(4));
	Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti2.getTypeAt(5));
	Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti2.getTypeAt(6));
	Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti2.getTypeAt(7));
	Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti2.getTypeAt(8));
	
	// test that getForClass does not work
	try {
		TypeExtractor.getForClass(Tuple9.class);
		Assert.fail("Exception expected here");
	} catch (InvalidTypesException e) {
		// that is correct
	}
}
 
Example #13
Source File: Tuple9Builder.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
	return tuples.toArray(new Tuple9[tuples.size()]);
}
 
Example #14
Source File: Tuple9Builder.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8){
	tuples.add(new Tuple9<>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
	return this;
}
 
Example #15
Source File: StreamProjection.java    From flink with 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, T8> SingleOutputStreamOperator<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return dataStream.transform("Projection", tType, new StreamProject<IN, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fieldIndexes, tType.createSerializer(dataStream.getExecutionConfig())));
}
 
Example #16
Source File: CrossOperator.java    From flink with 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, T8> ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);
}
 
Example #17
Source File: ProjectOperator.java    From flink with 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, T8> ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds, this.fieldIndexes, tType);
}
 
Example #18
Source File: JoinOperator.java    From Flink-CEPplus with 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, T8> ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);
}
 
Example #19
Source File: JoinOperator.java    From flink with 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, T8> ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);
}
 
Example #20
Source File: StreamProjection.java    From flink with 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, T8> SingleOutputStreamOperator<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return dataStream.transform("Projection", tType, new StreamProject<IN, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fieldIndexes, tType.createSerializer(dataStream.getExecutionConfig())));
}
 
Example #21
Source File: CrossOperator.java    From flink with 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, T8> ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);
}
 
Example #22
Source File: ProjectOperator.java    From flink with 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, T8> ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds, this.fieldIndexes, tType);
}
 
Example #23
Source File: JoinOperator.java    From flink with 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, T8> ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectJoin<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);
}
 
Example #24
Source File: StreamProjection.java    From Flink-CEPplus with 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, T8> SingleOutputStreamOperator<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return dataStream.transform("Projection", tType, new StreamProject<IN, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fieldIndexes, tType.createSerializer(dataStream.getExecutionConfig())));
}
 
Example #25
Source File: CrossOperator.java    From Flink-CEPplus with 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, T8> ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectCross<I1, I2, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);
}
 
Example #26
Source File: ProjectOperator.java    From Flink-CEPplus with 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, T8> ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> projectTuple9() {
	TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());
	TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tType = new TupleTypeInfo<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(fTypes);

	return new ProjectOperator<T, Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>(this.ds, this.fieldIndexes, tType);
}