imply-cheddar commented on code in PR #15463:
URL: https://github.com/apache/druid/pull/15463#discussion_r1410573788
##########
processing/src/main/java/org/apache/druid/java/util/common/granularity/Granularity.java:
##########
@@ -253,29 +247,33 @@ public enum Formatter
private class IntervalIterable implements Iterable<Interval>
{
private final Interval inputInterval;
+ private final int limit;
- private IntervalIterable(Interval inputInterval)
+ private IntervalIterable(Interval inputInterval, int limit)
{
this.inputInterval = inputInterval;
+ this.limit = limit;
}
@Override
public Iterator<Interval> iterator()
{
- return new IntervalIterator(inputInterval);
+ return new IntervalIterator(inputInterval, limit);
}
}
private class IntervalIterator implements Iterator<Interval>
{
private final Interval inputInterval;
+ private int limit;
private long currStart;
private long currEnd;
- private IntervalIterator(Interval inputInterval)
+ private IntervalIterator(Interval inputInterval, int limit)
{
this.inputInterval = inputInterval;
+ this.limit = limit;
Review Comment:
If a negative limit was passed it would hopefully fail some test somewhere
(would end up generating an exception saying that it's exceeding the limit).
And it would be better to use code review to "protect" from someone passing
`MAX_VALUE`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]