Github user tzulitai commented on a diff in the pull request:
https://github.com/apache/flink/pull/3915#discussion_r124964821
--- Diff:
flink-connectors/flink-connector-kafka-0.10/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumer010.java
---
@@ -128,6 +135,53 @@ public FlinkKafkaConsumer010(List<String> topics,
KeyedDeserializationSchema<T>
}
@Override
+ public FlinkKafkaConsumerBase<T> setStartFromSpecificDate(Date date) {
+ Preconditions.checkArgument(null != date && date.getTime() <=
System.currentTimeMillis(), "Startup time must before curr time.");
+ this.startupMode = StartupMode.SPECIFIC_TIMESTAMP;
+ this.specificStartupDate = date;
+ this.specificStartupOffsets = null;
+ return this;
+ }
+
+ /**
+ * Convert flink topic partition to kafka topic partition.
+ * @param flinkTopicPartitionMap
+ * @return
+ */
+ private Map<TopicPartition, Long>
convertFlinkToKafkaTopicPartition(Map<KafkaTopicPartition, Long>
flinkTopicPartitionMap) {
+ Map<TopicPartition, Long> topicPartitionMap = new
HashMap<>(flinkTopicPartitionMap.size());
+ for (Map.Entry<KafkaTopicPartition, Long> entry :
flinkTopicPartitionMap.entrySet()) {
+ topicPartitionMap.put(new
TopicPartition(entry.getKey().getTopic(), entry.getKey().getPartition()),
entry.getValue());
+ }
+
+ return topicPartitionMap;
+
+ }
+
+ /**
+ * Search offset from timestamp for each topic in kafka. If no offset
exist, use the latest offset.
+ * @param partitionTimesMap Kafka topic partition and timestamp
+ * @return Kafka topic partition and the earliest offset after the
timestamp. If no offset exist, use the latest offset in kafka
+ */
+ private Map<KafkaTopicPartition, Long>
convertTimestampToOffset(Map<KafkaTopicPartition, Long> partitionTimesMap) {
--- End diff --
Could you move these private aux methods to the end of the class? That
would benefit the readability / flow of the code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---