johnjcasey commented on code in PR #32889:
URL: https://github.com/apache/beam/pull/32889#discussion_r1822904512
##########
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/meta/provider/kafka/KafkaTestTable.java:
##########
@@ -163,8 +159,12 @@ public synchronized Map<TopicPartition,
OffsetAndTimestamp> offsetsForTimes(
}
};
- for (String topic : getTopics()) {
- consumer.updatePartitions(topic, partitionInfoMap.get(topic));
+ for (Map.Entry<TopicPartition, List<ConsumerRecord<byte[], byte[]>>> entry
:
+ kafkaRecords.entrySet()) {
+ consumer.updatePartitions(
Review Comment:
won't this update the partitions multiple times for each partition?
##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaUnboundedReader.java:
##########
@@ -711,23 +710,28 @@ private void setupInitialOffset(PartitionState<K, V>
pState) {
// Called from setupInitialOffset() at the start and then periodically from
offsetFetcher thread.
private void updateLatestOffsets() {
Consumer<byte[], byte[]> offsetConsumer =
Preconditions.checkStateNotNull(this.offsetConsumer);
- for (PartitionState<K, V> p : partitionStates) {
- try {
- Instant fetchTime = Instant.now();
- ConsumerSpEL.evaluateSeek2End(offsetConsumer, p.topicPartition);
- long offset = offsetConsumer.position(p.topicPartition);
- p.setLatestOffset(offset, fetchTime);
- } catch (Exception e) {
- if (closed.get()) { // Ignore the exception if the reader is closed.
- break;
- }
+ List<TopicPartition> topicPartitions =
+ Preconditions.checkStateNotNull(source.getSpec().getTopicPartitions());
+ Instant fetchTime = Instant.now();
+ try {
+ Map<TopicPartition, Long> endOffsets =
offsetConsumer.endOffsets(topicPartitions);
Review Comment:
do we need a separate offsetConsumer if we aren't seeking?
--
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]