本文整理汇总了Java中org.apache.flink.api.java.typeutils.PojoTypeInfo类的典型用法代码示例。如果您正苦于以下问题:Java PojoTypeInfo类的具体用法?Java PojoTypeInfo怎么用?Java PojoTypeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PojoTypeInfo类属于org.apache.flink.api.java.typeutils包,在下文中一共展示了PojoTypeInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: receive
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Override
public void receive(Event[] events) {
StreamRecord<R> reusableRecord = new StreamRecord<>(null, 0L);
for (Event event : events) {
if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
reusableRecord.replace(toMap(event), event.getTimestamp());
output.collect(reusableRecord);
} else if (typeInfo.isTupleType()) {
Tuple tuple = this.toTuple(event);
reusableRecord.replace(tuple, event.getTimestamp());
output.collect(reusableRecord);
} else if (typeInfo instanceof PojoTypeInfo) {
R obj;
try {
obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
} catch (IllegalArgumentException ex) {
LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
throw ex;
}
reusableRecord.replace(obj, event.getTimestamp());
output.collect(reusableRecord);
} else {
throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
}
}
}
开发者ID:haoch,项目名称:flink-siddhi,代码行数:27,代码来源:StreamOutputHandler.java
示例2: receive
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Override
public void receive(Event[] events) {
for (Event event : events) {
if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
collectedRecords.add(new StreamRecord<R>((R) toMap(event), event.getTimestamp()));
} else if (typeInfo.isTupleType()) {
Tuple tuple = this.toTuple(event);
collectedRecords.add(new StreamRecord<R>((R) tuple, event.getTimestamp()));
} else if (typeInfo instanceof PojoTypeInfo) {
R obj;
try {
obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
} catch (IllegalArgumentException ex) {
LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
throw ex;
}
collectedRecords.add(new StreamRecord<R>(obj, event.getTimestamp()));
} else {
throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
}
}
}
开发者ID:haoch,项目名称:flink-siddhi,代码行数:23,代码来源:StreamInMemOutputHandler.java
示例3: testStreamSchemaWithPojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testStreamSchemaWithPojo() {
TypeInformation<Event> typeInfo = TypeExtractor.createTypeInfo(Event.class);
assertTrue("Type information should be PojoTypeInfo", typeInfo instanceof PojoTypeInfo);
SiddhiStreamSchema<Event> schema = new SiddhiStreamSchema<>(typeInfo, "id", "timestamp", "name", "price");
assertEquals(4, schema.getFieldIndexes().length);
StreamDefinition streamDefinition = schema.getStreamDefinition("test_stream");
assertArrayEquals(new String[]{"id", "timestamp", "name", "price"}, streamDefinition.getAttributeNameArray());
assertEquals(Attribute.Type.INT, streamDefinition.getAttributeType("id"));
assertEquals(Attribute.Type.LONG, streamDefinition.getAttributeType("timestamp"));
assertEquals(Attribute.Type.STRING, streamDefinition.getAttributeType("name"));
assertEquals(Attribute.Type.DOUBLE, streamDefinition.getAttributeType("price"));
assertEquals("define stream test_stream (id int,timestamp long,name string,price double);", schema.getStreamDefinitionExpression("test_stream"));
}
开发者ID:haoch,项目名称:flink-siddhi,代码行数:19,代码来源:SiddhiExecutionPlanSchemaTest.java
示例4: receive
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Override
public void receive(Event[] events) {
StreamRecord<R> reusableRecord = new StreamRecord<>(null, 0L);
for (Event event : events) {
if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
reusableRecord.replace(toMap(event), event.getTimestamp());
output.collect(reusableRecord);
} else if (typeInfo.isTupleType()) {
Tuple tuple = this.toTuple(event);
reusableRecord.replace(tuple, event.getTimestamp());
output.collect(reusableRecord);
} else if (typeInfo instanceof PojoTypeInfo) {
R obj;
try {
obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
} catch (IllegalArgumentException ex) {
LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
throw ex;
}
reusableRecord.replace(obj, event.getTimestamp());
output.collect(reusableRecord);
} else {
throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
}
}
}
开发者ID:apache,项目名称:bahir-flink,代码行数:27,代码来源:StreamOutputHandler.java
示例5: receive
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Override
public void receive(Event[] events) {
for (Event event : events) {
if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
collectedRecords.add(new StreamRecord<R>((R) toMap(event), event.getTimestamp()));
} else if (typeInfo.isTupleType()) {
Tuple tuple = this.toTuple(event);
collectedRecords.add(new StreamRecord<R>((R) tuple, event.getTimestamp()));
} else if (typeInfo instanceof PojoTypeInfo) {
R obj;
try {
obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
} catch (IllegalArgumentException ex) {
LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
throw ex;
}
collectedRecords.add(new StreamRecord<R>(obj, event.getTimestamp()));
} else {
throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
}
}
}
开发者ID:apache,项目名称:bahir-flink,代码行数:23,代码来源:StreamInMemOutputHandler.java
示例6: testStreamSchemaWithPojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testStreamSchemaWithPojo() {
TypeInformation<Event> typeInfo = TypeExtractor.createTypeInfo(Event.class);
assertTrue("Type information should be PojoTypeInfo", typeInfo instanceof PojoTypeInfo);
SiddhiStreamSchema<Event> schema = new SiddhiStreamSchema<>(typeInfo, "id", "timestamp", "name", "price");
assertEquals(4, schema.getFieldIndexes().length);
StreamDefinition streamDefinition = schema.getStreamDefinition("test_stream");
assertArrayEquals(new String[]{"id", "timestamp", "name", "price"}, streamDefinition.getAttributeNameArray());
assertEquals(Attribute.Type.INT, streamDefinition.getAttributeType("id"));
assertEquals(Attribute.Type.LONG, streamDefinition.getAttributeType("timestamp"));
assertEquals(Attribute.Type.STRING, streamDefinition.getAttributeType("name"));
assertEquals(Attribute.Type.DOUBLE, streamDefinition.getAttributeType("price"));
assertEquals("define stream test_stream (id int,timestamp long,name string,price double);", schema.getStreamDefinitionExpression("test_stream"));
}
开发者ID:apache,项目名称:bahir-flink,代码行数:19,代码来源:SiddhiExecutionPlanSchemaTest.java
示例7: addSink
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
/**
* Writes a DataStream into a Cassandra database.
*
* @param input input DataStream
* @param <IN> input type
* @return CassandraSinkBuilder, to further configure the sink
*/
public static <IN> CassandraSinkBuilder<IN> addSink(DataStream<IN> input) {
TypeInformation<IN> typeInfo = input.getType();
if (typeInfo instanceof TupleTypeInfo) {
DataStream<Tuple> tupleInput = (DataStream<Tuple>) input;
return (CassandraSinkBuilder<IN>) new CassandraTupleSinkBuilder<>(tupleInput, tupleInput.getType(), tupleInput.getType().createSerializer(tupleInput.getExecutionEnvironment().getConfig()));
}
if (typeInfo instanceof RowTypeInfo) {
DataStream<Row> rowInput = (DataStream<Row>) input;
return (CassandraSinkBuilder<IN>) new CassandraRowSinkBuilder(rowInput, rowInput.getType(), rowInput.getType().createSerializer(rowInput.getExecutionEnvironment().getConfig()));
}
if (typeInfo instanceof PojoTypeInfo) {
return new CassandraPojoSinkBuilder<>(input, input.getType(), input.getType().createSerializer(input.getExecutionEnvironment().getConfig()));
}
if (typeInfo instanceof CaseClassTypeInfo) {
DataStream<Product> productInput = (DataStream<Product>) input;
return (CassandraSinkBuilder<IN>) new CassandraScalaProductSinkBuilder<>(productInput, productInput.getType(), productInput.getType().createSerializer(input.getExecutionEnvironment().getConfig()));
}
throw new IllegalArgumentException("No support for the type of the given DataStream: " + input.getType());
}
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:CassandraSink.java
示例8: testTypeExtraction
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testTypeExtraction() {
try {
InputFormat<MyAvroType, ?> format = new AvroInputFormat<MyAvroType>(new Path("file:///ignore/this/file"), MyAvroType.class);
TypeInformation<?> typeInfoDirect = TypeExtractor.getInputFormatTypes(format);
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<MyAvroType> input = env.createInput(format);
TypeInformation<?> typeInfoDataSet = input.getType();
Assert.assertTrue(typeInfoDirect instanceof PojoTypeInfo);
Assert.assertTrue(typeInfoDataSet instanceof PojoTypeInfo);
Assert.assertEquals(MyAvroType.class, typeInfoDirect.getTypeClass());
Assert.assertEquals(MyAvroType.class, typeInfoDataSet.getTypeClass());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:AvroInputFormatTypeExtractionTest.java
示例9: testPojoType
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoType() throws Exception {
File tempFile = File.createTempFile("CsvReaderPojoType", "tmp");
tempFile.deleteOnExit();
tempFile.setWritable(true);
OutputStreamWriter wrt = new OutputStreamWriter(new FileOutputStream(tempFile));
wrt.write("123,AAA,3.123,BBB\n");
wrt.write("456,BBB,1.123,AAA\n");
wrt.close();
@SuppressWarnings("unchecked")
PojoTypeInfo<PojoItem> typeInfo = (PojoTypeInfo<PojoItem>) TypeExtractor.createTypeInfo(PojoItem.class);
CsvInputFormat<PojoItem> inputFormat = new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo);
inputFormat.configure(new Configuration());
FileInputSplit[] splits = inputFormat.createInputSplits(1);
inputFormat.open(splits[0]);
validatePojoItem(inputFormat);
}
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:CsvInputFormatTest.java
示例10: testPojoTypeWithMappingInformation
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoTypeWithMappingInformation() throws Exception {
File tempFile = File.createTempFile("CsvReaderPojoType", "tmp");
tempFile.deleteOnExit();
tempFile.setWritable(true);
OutputStreamWriter wrt = new OutputStreamWriter(new FileOutputStream(tempFile));
wrt.write("123,3.123,AAA,BBB\n");
wrt.write("456,1.123,BBB,AAA\n");
wrt.close();
@SuppressWarnings("unchecked")
PojoTypeInfo<PojoItem> typeInfo = (PojoTypeInfo<PojoItem>) TypeExtractor.createTypeInfo(PojoItem.class);
CsvInputFormat<PojoItem> inputFormat = new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new String[]{"field1", "field3", "field2", "field4"});
inputFormat.configure(new Configuration());
FileInputSplit[] splits = inputFormat.createInputSplits(1);
inputFormat.open(splits[0]);
validatePojoItem(inputFormat);
}
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:CsvInputFormatTest.java
示例11: testPojoTypeWithPartialFieldInCSV
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoTypeWithPartialFieldInCSV() throws Exception {
File tempFile = File.createTempFile("CsvReaderPojoType", "tmp");
tempFile.deleteOnExit();
tempFile.setWritable(true);
OutputStreamWriter wrt = new OutputStreamWriter(new FileOutputStream(tempFile));
wrt.write("123,NODATA,AAA,NODATA,3.123,BBB\n");
wrt.write("456,NODATA,BBB,NODATA,1.123,AAA\n");
wrt.close();
@SuppressWarnings("unchecked")
PojoTypeInfo<PojoItem> typeInfo = (PojoTypeInfo<PojoItem>) TypeExtractor.createTypeInfo(PojoItem.class);
CsvInputFormat<PojoItem> inputFormat = new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new boolean[]{true, false, true, false, true, true});
inputFormat.configure(new Configuration());
FileInputSplit[] splits = inputFormat.createInputSplits(1);
inputFormat.open(splits[0]);
validatePojoItem(inputFormat);
}
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:CsvInputFormatTest.java
示例12: testPojoTypeWithMappingInfoAndPartialField
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoTypeWithMappingInfoAndPartialField() throws Exception {
File tempFile = File.createTempFile("CsvReaderPojoType", "tmp");
tempFile.deleteOnExit();
tempFile.setWritable(true);
OutputStreamWriter wrt = new OutputStreamWriter(new FileOutputStream(tempFile));
wrt.write("123,3.123,AAA,BBB\n");
wrt.write("456,1.123,BBB,AAA\n");
wrt.close();
@SuppressWarnings("unchecked")
PojoTypeInfo<PojoItem> typeInfo = (PojoTypeInfo<PojoItem>) TypeExtractor.createTypeInfo(PojoItem.class);
CsvInputFormat<PojoItem> inputFormat = new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new String[]{"field1", "field4"}, new boolean[]{true, false, false, true});
inputFormat.configure(new Configuration());
FileInputSplit[] splits = inputFormat.createInputSplits(1);
inputFormat.open(splits[0]);
PojoItem item = new PojoItem();
inputFormat.nextRecord(item);
assertEquals(123, item.field1);
assertEquals("BBB", item.field4);
}
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:CsvInputFormatTest.java
示例13: testTypeExtraction
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testTypeExtraction() {
try {
InputFormat<MyAvroType, ?> format = new AvroInputFormat<MyAvroType>(new Path("file:///ignore/this/file"), MyAvroType.class);
TypeInformation<?> typeInfoDirect = TypeExtractor.getInputFormatTypes(format);
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<MyAvroType> input = env.createInput(format);
TypeInformation<?> typeInfoDataSet = input.getType();
Assert.assertTrue(typeInfoDirect instanceof PojoTypeInfo);
Assert.assertTrue(typeInfoDataSet instanceof PojoTypeInfo);
Assert.assertEquals(MyAvroType.class, typeInfoDirect.getTypeClass());
Assert.assertEquals(MyAvroType.class, typeInfoDataSet.getTypeClass());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:AvroInputFormatTypeExtractionTest.java
示例14: testPojoInPojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoInPojo() {
Outer o = new Outer(10, new Inner(4L), (short) 12);
PojoTypeInfo<Outer> tpeInfo = (PojoTypeInfo<Outer>) TypeInformation.of(Outer.class);
FieldAccessor<Outer, Long> fix = FieldAccessorFactory.getAccessor(tpeInfo, "i.x", null);
assertEquals(4L, (long) fix.get(o));
assertEquals(4L, o.i.x);
o = fix.set(o, 22L);
assertEquals(22L, (long) fix.get(o));
assertEquals(22L, o.i.x);
FieldAccessor<Outer, Inner> fi = FieldAccessorFactory.getAccessor(tpeInfo, "i", null);
assertEquals(22L, fi.get(o).x);
assertEquals(22L, (long) fix.get(o));
assertEquals(22L, o.i.x);
o = fi.set(o, new Inner(30L));
assertEquals(30L, fi.get(o).x);
assertEquals(30L, (long) fix.get(o));
assertEquals(30L, o.i.x);
}
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:FieldAccessorTest.java
示例15: checkFromTuplePojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
private void checkFromTuplePojo(TypeInformation<?> typeInformation) {
Assert.assertTrue(typeInformation instanceof PojoTypeInfo<?>);
Assert.assertEquals(4, typeInformation.getTotalFields());
PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeInformation;
for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
PojoField field = pojoTypeForClass.getPojoFieldAt(i);
String name = field.field.getName();
if(name.equals("special")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.type);
} else if(name.equals("f0") || name.equals("f1")) {
Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.type);
} else if(name.equals("f2")) {
Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.type);
} else {
Assert.fail("unexpected field");
}
}
}
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:19,代码来源:PojoTypeExtractionTest.java
示例16: testPojoWithGenerics
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoWithGenerics() {
TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ParentSettingGenerics.class);
Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
PojoField field = pojoTypeForClass.getPojoFieldAt(i);
String name = field.field.getName();
if(name.equals("field1")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.type);
} else if (name.equals("field2")) {
Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.type);
} else if (name.equals("field3")) {
Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.type);
} else if (name.equals("key")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.type);
} else {
Assert.fail("Unexpected field "+field);
}
}
}
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:22,代码来源:PojoTypeExtractionTest.java
示例17: testPojoWithGenericsSomeFieldsGeneric
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
/**
* Test if the TypeExtractor is accepting untyped generics,
* making them GenericTypes
*/
@Test
@Ignore // kryo needed.
public void testPojoWithGenericsSomeFieldsGeneric() {
TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenerics.class);
Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
PojoField field = pojoTypeForClass.getPojoFieldAt(i);
String name = field.field.getName();
if(name.equals("field1")) {
Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.type);
} else if (name.equals("field2")) {
Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.type);
} else if (name.equals("key")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.type);
} else {
Assert.fail("Unexpected field "+field);
}
}
}
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:25,代码来源:PojoTypeExtractionTest.java
示例18: testPojoWithComplexHierarchy
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testPojoWithComplexHierarchy() {
TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ComplexHierarchyTop.class);
Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
PojoField field = pojoTypeForClass.getPojoFieldAt(i);
String name = field.field.getName();
if(name.equals("field1")) {
Assert.assertTrue(field.type instanceof PojoTypeInfo<?>); // From tuple is pojo (not tuple type!)
} else if (name.equals("field2")) {
Assert.assertTrue(field.type instanceof TupleTypeInfo<?>);
Assert.assertTrue( ((TupleTypeInfo<?>)field.type).getTypeAt(0).equals(BasicTypeInfo.STRING_TYPE_INFO) );
} else if (name.equals("key")) {
Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.type);
} else {
Assert.fail("Unexpected field "+field);
}
}
}
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:21,代码来源:PojoTypeExtractionTest.java
示例19: testStreamSchemaWithPojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testStreamSchemaWithPojo() {
TypeInformation<Event> typeInfo = TypeExtractor.createTypeInfo(Event.class);
assertTrue("Type information should be PojoTypeInfo", typeInfo instanceof PojoTypeInfo);
StreamSchema<Event> schema = new StreamSchema<>(typeInfo, "id", "timestamp", "name", "price");
assertEquals(4, schema.getFieldIndexes().length);
assertEquals(Event.class, schema.getTypeInfo().getTypeClass());
}
开发者ID:haoch,项目名称:flink-siddhi,代码行数:9,代码来源:StreamSchemaTest.java
示例20: testStreamTupleSerializerWithPojo
import org.apache.flink.api.java.typeutils.PojoTypeInfo; //导入依赖的package包/类
@Test
public void testStreamTupleSerializerWithPojo() {
TypeInformation<Event> typeInfo = TypeExtractor.createTypeInfo(Event.class);
assertTrue("Type information should be PojoTypeInfo", typeInfo instanceof PojoTypeInfo);
StreamSchema<Event> schema = new StreamSchema<>(typeInfo, "id", "timestamp", "name", "price");
assertEquals(Event.class, schema.getTypeInfo().getTypeClass());
TypeInformation<Tuple2<String, Event>> tuple2TypeInformation = TypeInfoParser.parse("Tuple2<String," + schema.getTypeInfo().getTypeClass().getName() + ">");
assertEquals("Java Tuple2<String, GenericType<" + Event.class.getName() + ">>", tuple2TypeInformation.toString());
}
开发者ID:haoch,项目名称:flink-siddhi,代码行数:11,代码来源:StreamSchemaTest.java
注:本文中的org.apache.flink.api.java.typeutils.PojoTypeInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论