@Override public String toString() { return String.valueOf(getGranularity()); } }
/** * Returns a list of contiguous time ranges, which fully encapsulate the given * range, provided the range is within the total range of the rollup structure. * * In cases where the rollup structure cannot fully encompass the given range, * as much of the rollup structure as possible will be used to cover the range. * * The resulting ranges are all of the same duration (the largest granularity). */ List<TimeRange> getEncompassingRanges(TimeRange range) { List<FrozenGranularityLayer> l = struct.getFrozenLayers(); FrozenGranularityLayer largest = l.get(l.size() - 1); TimeRange fillRange = range.augmentToOverlapWith(largest.getGranularity()); return largest.fillRange(fillRange); } }
List<FrozenCell> splitRange(FrozenCell cell) { if (!cell.canBeContainedByChildren()) { return Collections.emptyList(); } Granularity childGran = cell.getLayer().getChild().getGranularity(); if (childGran.isSmallerThan(minGran)) { return Collections.emptyList(); } return cell.getChildren(); } }
/** * @param timeRange The {@link TimeRange} which defines the start and end time of the cell. * @return A {@link FrozenCell} within the given granularity. */ public FrozenCell getCell(TimeRange timeRange) { FrozenCell res = cells.get(timeRange); if (res != null) { return res; } Granularity gran = getGranularity(); Time rangeStart = timeRange.getStartTime(); if (rangeStart.alignsOnGranularity(gran) == false) { throw new IllegalArgumentException("Range [" + timeRange + "] does not belong to this granularity [" + gran + "]"); } if (!canFullyContain(timeRange)) { throw new IllegalArgumentException("Range [" + timeRange + "] is not currently in scope for granularity [" + gran + "] " + " which has a total range of [" + getTotalRange() + "]"); } res = new FrozenCell(this, timeRange); cells.put(timeRange, res); return res; }
/** * Returns a map from granularity to the oldest datapoint which should * exist for it. */ GranularityTimes getOldestAllowedTimeForGranularity() { Time now = timeSvc.nowNanoTime(); FrozenRollUpStructure frozenStruct = this.struct.freeze(now); GranularityTimes res = new GranularityTimes(); for (FrozenGranularityLayer layer : frozenStruct.getFrozenLayers()) { res.put(layer.getGranularity(), layer.getTotalRange().getStartTime()); } return res; }