本文整理汇总了Java中org.apache.flink.api.java.tuple.Tuple9类的典型用法代码示例。如果您正苦于以下问题:Java Tuple9类的具体用法?Java Tuple9怎么用?Java Tuple9使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuple9类属于org.apache.flink.api.java.tuple包,在下文中一共展示了Tuple9类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTupleWithPrimitiveArray
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
@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));
}
示例2: newTuple
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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");
}
}
示例3: newTuple
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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");
}
}
示例4: add
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
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;
}
示例5: build
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
return tuples.toArray(new Tuple9[tuples.size()]);
}
示例6: testTupleWithBasicTypes
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
@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) TypeInfoParser.parse("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
}
}
示例7: add
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
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<T0, T1, T2, T3, T4, T5, T6, T7, T8>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
return this;
}
示例8: testTupleWithBasicTypes
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
@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) TypeInfoParser.parse("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).getKey("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
}
}
示例9: projectTuple9
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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);
}
示例10: projectTuple9
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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);
}
示例11: projectTuple9
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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);
}
示例12: projectTuple9
import org.apache.flink.api.java.tuple.Tuple9; //导入依赖的package包/类
/**
* 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())));
}