public class IntervalUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ALIGNMENT_EPOCH_STRING |
static org.joda.time.DateTime |
SYSTEM_ALIGNMENT_EPOCH |
static SystemConfig |
SYSTEM_CONFIG |
Constructor and Description |
---|
IntervalUtils() |
Modifier and Type | Method and Description |
---|---|
static SimplifiedIntervalList |
collectBucketedIntervalsIntersectingIntervalList(SimplifiedIntervalList supplyIntervals,
SimplifiedIntervalList bucketedIntervals,
Granularity granularity)
Collect all subintervals of an interval list of a grain bucketed size which are subintervals of another supply
list of intervals.
|
static long |
countSlicedIntervals(Collection<org.joda.time.Interval> rawIntervals,
Granularity grain)
Count the intervals after simplifying raw intervals and splitting by grain.
|
static Optional<org.joda.time.DateTime> |
firstMoment(Collection<? extends Collection<org.joda.time.Interval>> intervalSets)
Return the first date time instant in this set of intervals if available.
|
static Stream<org.joda.time.Interval> |
getIntervalOverlaps(org.joda.time.Interval interval,
Collection<org.joda.time.Interval> compareIntervals)
For a given interval, return a stream of the subintervals of it that are shared with at least one interval
in the collection of compare intervals.
|
static Set<org.joda.time.Interval> |
getOverlappingSubintervals(Collection<org.joda.time.Interval> left,
Collection<org.joda.time.Interval> right)
Find all the interval overlaps between two collections of intervals.
|
static Set<org.joda.time.Interval> |
getOverlappingSubintervals(Set<org.joda.time.Interval> left,
Set<org.joda.time.Interval> right)
Find all the interval overlaps between two collections of intervals.
|
static Map<org.joda.time.Interval,AtomicInteger> |
getSlicedIntervals(Collection<org.joda.time.Interval> rawIntervals,
Granularity grain)
Simplify raw intervals and return a map of intervals (dividing them by the grain) to the ordinal of the interval.
|
static Optional<TimeGrain> |
getTimeGrain(org.joda.time.Interval interval)
Find a valid timegrain for the interval based on the start and end date of the interval.
|
static long |
getTotalDuration(Collection<org.joda.time.Interval> intervals)
Sum the length of the intervals in this collection.
|
public static final SystemConfig SYSTEM_CONFIG
public static final String ALIGNMENT_EPOCH_STRING
public static final org.joda.time.DateTime SYSTEM_ALIGNMENT_EPOCH
public static Stream<org.joda.time.Interval> getIntervalOverlaps(org.joda.time.Interval interval, Collection<org.joda.time.Interval> compareIntervals)
interval
- The interval being matchedcompareIntervals
- The collection of intervals being matched againstpublic static Set<org.joda.time.Interval> getOverlappingSubintervals(Collection<org.joda.time.Interval> left, Collection<org.joda.time.Interval> right)
If the left set is null, return the right. This makes this usable in a reduce function.
left
- The intervals being streamed overright
- The intervals being tested againstpublic static Set<org.joda.time.Interval> getOverlappingSubintervals(Set<org.joda.time.Interval> left, Set<org.joda.time.Interval> right)
If the left set is null, return the right. This makes this usable in a reduce function.
left
- The intervals being streamed overright
- The intervals being tested againstpublic static Map<org.joda.time.Interval,AtomicInteger> getSlicedIntervals(Collection<org.joda.time.Interval> rawIntervals, Granularity grain)
rawIntervals
- A collection of intervals to be splitgrain
- The grain to split by.public static long countSlicedIntervals(Collection<org.joda.time.Interval> rawIntervals, Granularity grain)
rawIntervals
- A collection of intervals to be splitgrain
- The grain to split by.public static SimplifiedIntervalList collectBucketedIntervalsIntersectingIntervalList(SimplifiedIntervalList supplyIntervals, SimplifiedIntervalList bucketedIntervals, Granularity granularity)
supplyIntervals
- The interval collection to match bucketedIntervals againstbucketedIntervals
- The grain bucketed intervals to collect if they overlap the supplygranularity
- Grain at which to split the bucketingIntervalspublic static long getTotalDuration(Collection<org.joda.time.Interval> intervals)
intervals
- A collection of time intervalspublic static Optional<org.joda.time.DateTime> firstMoment(Collection<? extends Collection<org.joda.time.Interval>> intervalSets)
intervalSets
- A collection of intervals setsCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.