org.apache.flink.formats.avro.typeutils.GenericRecordAvroTypeInfo Java Examples
The following examples show how to use
org.apache.flink.formats.avro.typeutils.GenericRecordAvroTypeInfo.
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: AvroStreamingFileSinkITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWriteAvroGeneric() throws Exception { File folder = TEMPORARY_FOLDER.newFolder(); Schema schema = Address.getClassSchema(); Collection<GenericRecord> data = new GenericTestDataCollection(); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.enableCheckpointing(100); AvroWriterFactory<GenericRecord> avroWriterFactory = AvroWriters.forGenericRecord(schema); DataStream<GenericRecord> stream = env.addSource( new FiniteTestSource<>(data), new GenericRecordAvroTypeInfo(schema)); stream.addSink(StreamingFileSink.forBulkFormat( Path.fromLocalFile(folder), avroWriterFactory).build()); env.execute(); validateResults(folder, new GenericDatumReader<>(schema), new ArrayList<>(data)); }
Example #2
Source File: AvroDeserializationSchema.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public TypeInformation<T> getProducedType() { if (SpecificRecord.class.isAssignableFrom(recordClazz)) { return new AvroTypeInfo(recordClazz); } else { return (TypeInformation<T>) new GenericRecordAvroTypeInfo(this.reader); } }
Example #3
Source File: ParquetStreamingFileSinkITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWriteParquetAvroGeneric() throws Exception { final File folder = TEMPORARY_FOLDER.newFolder(); final Schema schema = Address.getClassSchema(); final Collection<GenericRecord> data = new GenericTestDataCollection(); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.enableCheckpointing(100); DataStream<GenericRecord> stream = env.addSource( new FiniteTestSource<>(data), new GenericRecordAvroTypeInfo(schema)); stream.addSink( StreamingFileSink.forBulkFormat( Path.fromLocalFile(folder), ParquetAvroWriters.forGenericRecord(schema)) .build()); env.execute(); List<Address> expected = Arrays.asList( new Address(1, "a", "b", "c", "12345"), new Address(2, "x", "y", "z", "98765")); validateResults(folder, SpecificData.get(), expected); }
Example #4
Source File: AvroDeserializationSchema.java From flink with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public TypeInformation<T> getProducedType() { if (SpecificRecord.class.isAssignableFrom(recordClazz)) { return new AvroTypeInfo(recordClazz); } else { return (TypeInformation<T>) new GenericRecordAvroTypeInfo(this.reader); } }
Example #5
Source File: ParquetStreamingFileSinkITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWriteParquetAvroGeneric() throws Exception { final File folder = TEMPORARY_FOLDER.newFolder(); final Schema schema = Address.getClassSchema(); final Collection<GenericRecord> data = new GenericTestDataCollection(); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.enableCheckpointing(100); DataStream<GenericRecord> stream = env.addSource( new FiniteTestSource<>(data), new GenericRecordAvroTypeInfo(schema)); stream.addSink( StreamingFileSink.forBulkFormat( Path.fromLocalFile(folder), ParquetAvroWriters.forGenericRecord(schema)) .build()); env.execute(); List<Address> expected = Arrays.asList( new Address(1, "a", "b", "c", "12345"), new Address(2, "x", "y", "z", "98765")); validateResults(folder, SpecificData.get(), expected); }
Example #6
Source File: AvroDeserializationSchema.java From flink with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public TypeInformation<T> getProducedType() { if (SpecificRecord.class.isAssignableFrom(recordClazz)) { return new AvroTypeInfo(recordClazz); } else { return (TypeInformation<T>) new GenericRecordAvroTypeInfo(this.reader); } }
Example #7
Source File: ParquetStreamingFileSinkITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWriteParquetAvroGeneric() throws Exception { final File folder = TEMPORARY_FOLDER.newFolder(); final Schema schema = Address.getClassSchema(); final Collection<GenericRecord> data = new GenericTestDataCollection(); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.enableCheckpointing(100); DataStream<GenericRecord> stream = env.addSource( new FiniteTestSource<>(data), new GenericRecordAvroTypeInfo(schema)); stream.addSink( StreamingFileSink.forBulkFormat( Path.fromLocalFile(folder), ParquetAvroWriters.forGenericRecord(schema)) .build()); env.execute(); List<Address> expected = Arrays.asList( new Address(1, "a", "b", "c", "12345"), new Address(2, "x", "y", "z", "98765")); validateResults(folder, SpecificData.get(), expected); }
Example #8
Source File: SerializationFrameworkAllBenchmarks.java From flink-benchmarks with Apache License 2.0 | 4 votes |
public AvroGenericRecordSource(int numEvents, int numKeys, Schema schema) { super(numEvents, numKeys); this.producedType = new GenericRecordAvroTypeInfo(schema); this.myPojoSchema = schema; this.schemaString = schema.toString(); }