martongreber commented on code in PR #8: URL: https://github.com/apache/flink-connector-kudu/pull/8#discussion_r1977732794
########## flink-connector-kudu/src/main/java/org/apache/flink/connector/kudu/source/reader/KuduSourceReader.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.connector.kudu.source.reader; + +import org.apache.flink.api.connector.source.SourceReaderContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.connector.base.source.reader.SingleThreadMultiplexSourceReaderBase; +import org.apache.flink.connector.base.source.reader.splitreader.SplitReader; +import org.apache.flink.connector.kudu.connector.converter.RowResultConverter; +import org.apache.flink.connector.kudu.source.split.KuduSourceSplit; +import org.apache.flink.connector.kudu.source.split.SplitFinishedEvent; + +import java.util.ArrayList; +import java.util.Map; +import java.util.function.Supplier; + +/** + * The Kudu source reader. + * + * @param <OUT> the type of records read from the source. + */ +public class KuduSourceReader<OUT> + extends SingleThreadMultiplexSourceReaderBase<OUT, OUT, KuduSourceSplit, KuduSourceSplit> { + + public KuduSourceReader( + Supplier<SplitReader<OUT, KuduSourceSplit>> splitReaderSupplier, + Configuration config, + SourceReaderContext context, + RowResultConverter rowResultConverter) { + super(splitReaderSupplier, new KuduRecordEmitter<>(rowResultConverter), config, context); + } + + @Override + protected void onSplitFinished(Map<String, KuduSourceSplit> finishedSplits) { Review Comment: yea valid question. the main idea is that we try to keep track of unassigned/pending splits on the enumerator level. in order to signal back the actual finished split from the reader, i use the SplitFinishedEvent. in the enumerator when this event is handled, we call the appropriate logic to add this reader to the readers awating split, and call the assignment logic. this is what i've came up with, maybe there is an other way, I'm happy to discuss. ########## flink-connector-kudu/src/main/java/org/apache/flink/connector/kudu/source/reader/KuduSourceReader.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.connector.kudu.source.reader; + +import org.apache.flink.api.connector.source.SourceReaderContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.connector.base.source.reader.SingleThreadMultiplexSourceReaderBase; +import org.apache.flink.connector.base.source.reader.splitreader.SplitReader; +import org.apache.flink.connector.kudu.connector.converter.RowResultConverter; +import org.apache.flink.connector.kudu.source.split.KuduSourceSplit; +import org.apache.flink.connector.kudu.source.split.SplitFinishedEvent; + +import java.util.ArrayList; +import java.util.Map; +import java.util.function.Supplier; + +/** + * The Kudu source reader. + * + * @param <OUT> the type of records read from the source. + */ +public class KuduSourceReader<OUT> + extends SingleThreadMultiplexSourceReaderBase<OUT, OUT, KuduSourceSplit, KuduSourceSplit> { + + public KuduSourceReader( + Supplier<SplitReader<OUT, KuduSourceSplit>> splitReaderSupplier, + Configuration config, + SourceReaderContext context, + RowResultConverter rowResultConverter) { + super(splitReaderSupplier, new KuduRecordEmitter<>(rowResultConverter), config, context); + } + + @Override + protected void onSplitFinished(Map<String, KuduSourceSplit> finishedSplits) { Review Comment: yea valid question. the main idea is that we try to keep track of unassigned/pending splits on the enumerator level. in order to signal back the actual finished split from the reader, i use the SplitFinishedEvent. in the enumerator when this event is handled, we call the appropriate logic to add this reader to the readers awaiting split, and call the assignment logic. this is what i've came up with, maybe there is an other way, I'm happy to discuss. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
