[ 
https://issues.apache.org/jira/browse/FLINK-13864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16917708#comment-16917708
 ] 

Kailash Hassan Dayanand commented on FLINK-13864:
-------------------------------------------------

Hello [~kkl0u],

Thanks for your response. Wanted to include some code snippets which will make 
the discussion easier. This is my current extended class:

public class ExtendedtStreamingFileSink<INT> extends StreamingFileSink<INT> {

public static <INT> StreamingFileSink.BulkFormatBuilder<INT, String> 
forBulkFormat(
 Path basePath, Factory<INT> writerFactory) {
  return new ExtendedtStreamingFileSink.ExtendedBulkFormatBuilder(
  basePath, writerFactory, new DateTimeBucketAssigner());
}

public static class ExtendedBulkFormatBuilder<INT, BucketIDT>
 extends StreamingFileSink.BulkFormatBuilder<INT, BucketIDT> {
 

public <IDT> ExtendedtStreamingFileSink.ExtendedBulkFormatBuilder<INT, IDT> 
withBucketAssigner(
 BucketAssigner<INT, IDT> assigner) {

return new ExtendedtStreamingFileSink.ExtendedBulkFormatBuilder(
 super.basePath,
 super.writerFactory,
 (BucketAssigner) Preconditions.checkNotNull(assigner),
 this.bucketCheckInterval,
 new DefaultBucketFactoryImpl());

}

... similar function for other functions: withBucketCheckInterval, 

// Constructors

public ExtendedBulkFormatBuilder(
 Path basePath, Factory<INT> writerFactory, BucketAssigner<INT, BucketIDT> 
assigner) {
 super(basePath, writerFactory, assigner);
}

private ExtendedBulkFormatBuilder(
 Path basePath,
 Factory<INT> writerFactory,
 BucketAssigner<INT, BucketIDT> assigner,
 long bucketCheckInterval,
 BucketFactory<INT, BucketIDT> bucketFactory) {
 super(basePath, writerFactory, assigner, bucketCheckInterval, bucketFactory);
}

}

Since I am using the private members of the StreamingFileSink.Builder class in 
the extendedBuilder class, I changed them to protected. But this may not be 
completely necessary and I could use some mechanism described here: 
[https://stackoverflow.com/questions/17164375/subclassing-a-java-builder-class] 
which may this recommended change unnecessary.

> StreamingFileSink: Allow inherited classes to extend StreamingFileSink 
> correctly
> --------------------------------------------------------------------------------
>
>                 Key: FLINK-13864
>                 URL: https://issues.apache.org/jira/browse/FLINK-13864
>             Project: Flink
>          Issue Type: Improvement
>          Components: Connectors / FileSystem
>            Reporter: Kailash Hassan Dayanand
>            Priority: Minor
>
> Currently the StreamingFileSink can't be extended correctly as there are a 
> few issues [PR |[https://github.com/apache/flink/pull/8469]] merged for  this 
> [Jira|https://issues.apache.org/jira/browse/FLINK-12539]
> Mailing list discussion: 
> [http://mail-archives.apache.org/mod_mbox/flink-dev/201908.mbox/%3CCACGLQUAxXjr2mBOf-6hbXcwmWoH5ib_0YEy-Vyjj%3DEPyQ25Qiw%40mail.gmail.com%3E]
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to