waitingF commented on code in PR #8376:
URL: https://github.com/apache/hudi/pull/8376#discussion_r1176087633
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/KafkaOffsetGen.java:
##########
@@ -107,48 +112,119 @@ public static String offsetsToStr(OffsetRange[] ranges) {
* @param numEvents maximum number of events to read.
*/
public static OffsetRange[] computeOffsetRanges(Map<TopicPartition, Long>
fromOffsetMap,
- Map<TopicPartition, Long>
toOffsetMap, long numEvents) {
-
- Comparator<OffsetRange> byPartition =
Comparator.comparing(OffsetRange::partition);
-
- // Create initial offset ranges for each 'to' partition, with from = to
offsets.
+ Map<TopicPartition, Long>
toOffsetMap,
+ long numEvents,
+ long minPartitions) {
+ // Create initial offset ranges for each 'to' partition, with default
from = 0 offsets.
OffsetRange[] ranges = toOffsetMap.keySet().stream().map(tp -> {
long fromOffset = fromOffsetMap.getOrDefault(tp, 0L);
- return OffsetRange.create(tp, fromOffset, fromOffset);
+ return OffsetRange.create(tp, fromOffset, toOffsetMap.get(tp));
})
- .sorted(byPartition)
+ .sorted(SORT_BY_PARTITION)
.collect(Collectors.toList())
.toArray(new OffsetRange[toOffsetMap.size()]);
+ LOG.debug("numEvents {}, minPartitions {}, ranges {}", numEvents,
minPartitions, ranges);
+ boolean needSplitToMinPartitions = minPartitions > toOffsetMap.size();
+ long totalEvents = totalNewMessages(ranges);
long allocedEvents = 0;
Set<Integer> exhaustedPartitions = new HashSet<>();
+ List<OffsetRange> finalRanges = new ArrayList<>();
+ // choose the numEvents with min(totalEvents, numEvents)
+ numEvents = Math.min(totalEvents, numEvents);
Review Comment:
done
--
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]