Class JodaUtils
java.lang.Object
org.apache.druid.java.util.common.JodaUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Iterator<org.joda.time.Interval> condensedIntervalsIterator(Iterator<org.joda.time.Interval> sortedIntervals) Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.static List<org.joda.time.Interval> condenseIntervals(Iterable<org.joda.time.Interval> intervals) Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.static org.joda.time.DateTimemaxDateTime(org.joda.time.DateTime... times) static org.joda.time.DateTimeminDateTime(org.joda.time.DateTime... times) static org.joda.time.IntervalumbrellaInterval(Iterable<org.joda.time.Interval> intervals)
-
Field Details
-
MAX_INSTANT
public static final long MAX_INSTANT- See Also:
-
MIN_INSTANT
public static final long MIN_INSTANT- See Also:
-
-
Constructor Details
-
JodaUtils
public JodaUtils()
-
-
Method Details
-
condenseIntervals
public static List<org.joda.time.Interval> condenseIntervals(Iterable<org.joda.time.Interval> intervals) Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.This method is most efficient if the input intervals are in a
SortedSetwhose comparator isComparators.intervalsByStartThenEnd().- Parameters:
intervals- The Iterable object containing the intervals to condense- Returns:
- The condensed intervals
-
condensedIntervalsIterator
public static Iterator<org.joda.time.Interval> condensedIntervalsIterator(Iterator<org.joda.time.Interval> sortedIntervals) Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.The provided intervals must be sorted in ascending order using
Comparators.intervalsByStartThenEnd(). Otherwise, results are undefined.The method avoids materialization by incrementally condensing the intervals by starting from the first and looking for "adjacent" intervals. This is possible since intervals in the Iterator are in ascending order (as guaranteed by the caller).
- Parameters:
sortedIntervals- The iterator object containing the intervals to condense- Returns:
- An iterator for the condensed intervals. By construction the condensed intervals are sorted in ascending order and contain no repeated elements. The iterator can contain nulls, they will be skipped if it does.
- Throws:
IAE- if an element is null or if sortedIntervals is not sorted in ascending order
-
umbrellaInterval
-
minDateTime
public static org.joda.time.DateTime minDateTime(org.joda.time.DateTime... times) -
maxDateTime
public static org.joda.time.DateTime maxDateTime(org.joda.time.DateTime... times)
-