Class JodaUtils
- java.lang.Object
-
- org.apache.druid.java.util.common.JodaUtils
-
public class JodaUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_INSTANT
static long
MIN_INSTANT
-
Constructor Summary
Constructors Constructor Description JodaUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.DateTime
maxDateTime(org.joda.time.DateTime... times)
static org.joda.time.DateTime
minDateTime(org.joda.time.DateTime... times)
static org.joda.time.Interval
umbrellaInterval(Iterable<org.joda.time.Interval> intervals)
-
-
-
Field Detail
-
MAX_INSTANT
public static final long MAX_INSTANT
- See Also:
- Constant Field Values
-
MIN_INSTANT
public static final long MIN_INSTANT
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
SortedSet
whose 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
public static org.joda.time.Interval umbrellaInterval(Iterable<org.joda.time.Interval> intervals)
-
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)
-
-