org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner Java Examples

The following examples show how to use org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner. 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: DateTimeBucketAssigner.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public String getBucketId(IN element, BucketAssigner.Context context) {
	if (dateTimeFormatter == null) {
		dateTimeFormatter = DateTimeFormatter.ofPattern(formatString).withZone(zoneId);
	}
	return dateTimeFormatter.format(Instant.ofEpochMilli(context.currentProcessingTime()));
}
 
Example #2
Source File: DateTimeBucketAssigner.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public String getBucketId(IN element, BucketAssigner.Context context) {
	if (dateTimeFormatter == null) {
		dateTimeFormatter = DateTimeFormatter.ofPattern(formatString).withZone(zoneId);
	}
	return dateTimeFormatter.format(Instant.ofEpochMilli(context.currentProcessingTime()));
}
 
Example #3
Source File: CompressWriterFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private File prepareCompressedFile(CompressWriterFactory<String> writer, List<String> lines) throws Exception {
	final File outDir = TEMPORARY_FOLDER.newFolder();

	final BucketAssigner<String, String> assigner = new BucketAssigner<String, String> () {
		@Override
		public String getBucketId(String element, BucketAssigner.Context context) {
			return "bucket";
		}

		@Override
		public SimpleVersionedSerializer<String> getSerializer() {
			return SimpleVersionedStringSerializer.INSTANCE;
		}
	};

	StreamingFileSink<String> sink = StreamingFileSink
		.forBulkFormat(new Path(outDir.toURI()), writer)
		.withBucketAssigner(assigner)
		.build();

	try (
		OneInputStreamOperatorTestHarness<String, Object> testHarness = new OneInputStreamOperatorTestHarness<>(new StreamSink<>(sink), 1, 1, 0)
	) {
		testHarness.setup();
		testHarness.open();

		int time = 0;
		for (String line: lines) {
			testHarness.processElement(new StreamRecord<>(line, ++time));
		}

		testHarness.snapshot(1, ++time);
		testHarness.notifyOfCompletedCheckpoint(1);
	}

	return outDir;
}
 
Example #4
Source File: DateTimeBucketAssigner.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public String getBucketId(IN element, BucketAssigner.Context context) {
	if (dateTimeFormatter == null) {
		dateTimeFormatter = DateTimeFormatter.ofPattern(formatString).withZone(zoneId);
	}
	return dateTimeFormatter.format(Instant.ofEpochMilli(context.currentProcessingTime()));
}
 
Example #5
Source File: BasePathBucketAssigner.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public String getBucketId(T element, BucketAssigner.Context context) {
	return "";
}
 
Example #6
Source File: BasePathBucketAssigner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String getBucketId(T element, BucketAssigner.Context context) {
	return "";
}
 
Example #7
Source File: BasePathBucketAssigner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String getBucketId(T element, BucketAssigner.Context context) {
	return "";
}