org.apache.flink.formats.parquet.generated.Address Java Examples

The following examples show how to use org.apache.flink.formats.parquet.generated.Address. 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: ParquetStreamingFileSinkITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public Iterator<GenericRecord> iterator() {
	final GenericRecord rec1 = new GenericData.Record(Address.getClassSchema());
	rec1.put(0, 1);
	rec1.put(1, "a");
	rec1.put(2, "b");
	rec1.put(3, "c");
	rec1.put(4, "12345");

	final GenericRecord rec2 = new GenericData.Record(Address.getClassSchema());
	rec2.put(0, 2);
	rec2.put(1, "x");
	rec2.put(2, "y");
	rec2.put(3, "z");
	rec2.put(4, "98765");

	return Arrays.asList(rec1, rec2).iterator();
}
 
Example #2
Source File: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Iterator<GenericRecord> iterator() {
	final GenericRecord rec1 = new GenericData.Record(Address.getClassSchema());
	rec1.put(0, 1);
	rec1.put(1, "a");
	rec1.put(2, "b");
	rec1.put(3, "c");
	rec1.put(4, "12345");

	final GenericRecord rec2 = new GenericData.Record(Address.getClassSchema());
	rec2.put(0, 2);
	rec2.put(1, "x");
	rec2.put(2, "y");
	rec2.put(3, "z");
	rec2.put(4, "98765");

	return Arrays.asList(rec1, rec2).iterator();
}
 
Example #3
Source File: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Iterator<GenericRecord> iterator() {
	final GenericRecord rec1 = new GenericData.Record(Address.getClassSchema());
	rec1.put(0, 1);
	rec1.put(1, "a");
	rec1.put(2, "b");
	rec1.put(3, "c");
	rec1.put(4, "12345");

	final GenericRecord rec2 = new GenericData.Record(Address.getClassSchema());
	rec2.put(0, 2);
	rec2.put(1, "x");
	rec2.put(2, "y");
	rec2.put(3, "z");
	rec2.put(4, "98765");

	return Arrays.asList(rec1, rec2).iterator();
}
 
Example #4
Source File: ParquetStreamingFileSinkITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteParquetAvroSpecific() throws Exception {

	final File folder = TEMPORARY_FOLDER.newFolder();

	final List<Address> data = Arrays.asList(
			new Address(1, "a", "b", "c", "12345"),
			new Address(2, "p", "q", "r", "12345"),
			new Address(3, "x", "y", "z", "12345")
	);

	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);
	env.enableCheckpointing(100);

	DataStream<Address> stream = env.addSource(
			new FiniteTestSource<>(data), TypeInformation.of(Address.class));

	stream.addSink(
			StreamingFileSink.forBulkFormat(
					Path.fromLocalFile(folder),
					ParquetAvroWriters.forSpecificRecord(Address.class))
			.build());

	env.execute();

	validateResults(folder, SpecificData.get(), data);
}
 
Example #5
Source File: ParquetStreamingFileSinkITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteParquetAvroSpecific() throws Exception {

	final File folder = TEMPORARY_FOLDER.newFolder();

	final List<Address> data = Arrays.asList(
			new Address(1, "a", "b", "c", "12345"),
			new Address(2, "p", "q", "r", "12345"),
			new Address(3, "x", "y", "z", "12345")
	);

	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);
	env.enableCheckpointing(100);

	DataStream<Address> stream = env.addSource(
			new FiniteTestSource<>(data), TypeInformation.of(Address.class));

	stream.addSink(
			StreamingFileSink.forBulkFormat(
					Path.fromLocalFile(folder),
					ParquetAvroWriters.forSpecificRecord(Address.class))
			.build());

	env.execute();

	validateResults(folder, SpecificData.get(), data);
}
 
Example #7
Source File: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@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: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteParquetAvroSpecific() throws Exception {

	final File folder = TEMPORARY_FOLDER.newFolder();

	final List<Address> data = Arrays.asList(
			new Address(1, "a", "b", "c", "12345"),
			new Address(2, "p", "q", "r", "12345"),
			new Address(3, "x", "y", "z", "12345")
	);

	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.setParallelism(1);
	env.enableCheckpointing(100);

	DataStream<Address> stream = env.addSource(
			new FiniteTestSource<>(data), TypeInformation.of(Address.class));

	stream.addSink(
			StreamingFileSink.forBulkFormat(
					Path.fromLocalFile(folder),
					ParquetAvroWriters.forSpecificRecord(Address.class))
			.build());

	env.execute();

	validateResults(folder, SpecificData.get(), data);
}
 
Example #9
Source File: ParquetStreamingFileSinkITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}