public TimePartitionRange emptyRange() throws LensException { return this.rangeUpto(this); }
public TimePartitionRange emptyRange() throws LensException { return this.rangeUpto(this); }
public TimePartitionRange singletonRange() throws LensException { return rangeUpto(next()); }
public TimePartitionRange singletonRange() throws LensException { return rangeUpto(next()); }
public static TimePartitionRange between(Date from, Date to, UpdatePeriod period) throws LensException { return TimePartition.of(period, from).rangeUpto(TimePartition.of(period, to)); }
public static TimePartitionRange between(Date from, Date to, UpdatePeriod period) throws LensException { return TimePartition.of(period, from).rangeUpto(TimePartition.of(period, to)); }
@Test(expectedExceptions = LensException.class) public void testTimeRangeCreationWithDifferentUpdatePeriod() throws LensException { // begin and end partitions should have same update period for range creation to succeed. TimePartition.of(UpdatePeriod.HOURLY, NOW).rangeUpto(TimePartition.of(UpdatePeriod.DAILY, NOW)); }
TimePartitionRange range = nowPartition.rangeUpto(tenLater); assertEquals(range, tenLater.rangeFrom(nowPartition)); assertEquals(TimePartitionRange.parseFrom(up, "[" + nowStr, tenLaterStr + ")"), range); assertEquals(TimePartitionRange.parseFrom(up, "[" + nowStr, tenLaterStr + "]"), nowPartition.rangeUpto(tenLater.next())); assertEquals(TimePartitionRange.parseFrom(up, "(" + nowStr, tenLaterStr + "]"), nowPartition.next().rangeUpto( tenLater.next())); assertEquals(TimePartitionRange.parseFrom(up, "(" + nowStr, tenLaterStr + ")"), nowPartition.next().rangeUpto(tenLater));
public void add(String partCol, TimePartition partition) throws LensException { if (get(partCol) == null) { put(partCol, new RangesPartitionTimeline("", UpdatePeriod.values()[0], partCol)); } get(partCol).add(partition.withUpdatePeriod(UpdatePeriod.values()[0]) .rangeUpto(partition.next().withUpdatePeriod(UpdatePeriod.values()[0]))); }
public void add(String partCol, TimePartition partition) throws LensException { if (get(partCol) == null) { put(partCol, new RangesPartitionTimeline("", UpdatePeriod.values()[0], partCol)); } get(partCol).add(partition.withUpdatePeriod(UpdatePeriod.values()[0]) .rangeUpto(partition.next().withUpdatePeriod(UpdatePeriod.values()[0]))); }
TimePartition.of(HOURLY, getDateWithOffset(DAILY, -2)).rangeUpto(TimePartition.of(HOURLY, ceilDay)), TimePartition.of(DAILY, ceilDay).rangeUpto(TimePartition.of(DAILY, nextDay)), TimePartition.of(HOURLY, nextDay).rangeUpto(TimePartition.of(HOURLY, NOW)))) { FactPartition fp = new FactPartition("it", p, null, storageTables); expectedPartsQueried.add(fp); for (TimePartition it : TimePartition.of(HOURLY, ceilDay).rangeUpto(TimePartition.of(HOURLY, nextDay))) { for (TimePartition pt : TimePartition.of(HOURLY, nextDay).rangeUpto(TimePartition.of(HOURLY, nextToNextDay))) { FactPartition ptPartition = new FactPartition("pt", pt, null, storageTables); FactPartition itPartition = new FactPartition("it", it, ptPartition, storageTables); TimePartition.of(HOURLY, getDateWithOffset(DAILY, -3)).rangeUpto(TimePartition.of(HOURLY, ceilDay)), TimePartition.of(DAILY, ceilDay).rangeUpto(TimePartition.of(DAILY, nextDay)), TimePartition.of(DAILY, nextDay).rangeUpto(TimePartition.of(DAILY, nextToNextDay)), TimePartition.of(HOURLY, nextToNextDay).rangeUpto(TimePartition.of(HOURLY, NOW)))) { FactPartition fp = new FactPartition("it", p, null, storageTables); expectedPartsQueried.add(fp); for (TimePartition it : TimePartition.of(HOURLY, ceilDay).rangeUpto(TimePartition.of(HOURLY, nextDay))) { for (TimePartition pt : TimePartition.of(HOURLY, nextDay).rangeUpto(TimePartition.of(HOURLY, nextToNextDay))) { FactPartition ptPartition = new FactPartition("pt", pt, null, storageTables); FactPartition itPartition = new FactPartition("it", it, ptPartition, storageTables); for (TimePartition it : TimePartition.of(HOURLY, ceilDay).rangeUpto(TimePartition.of(HOURLY, nextDay))) { for (TimePartition pt : TimePartition.of(HOURLY, nextDay).rangeUpto(TimePartition.of(HOURLY, nextToNextDay))) { FactPartition ptPartition = new FactPartition("pt", pt, null, storageTables); FactPartition itPartition = new FactPartition("it", it, ptPartition, storageTables);
@Override public boolean drop(TimePartition toDrop) throws LensException { int ind = getStrictlyAfterIndex(toDrop); if (ind == 0) { return true; // nothing to do } if (ranges.get(ind - 1).getBegin().equals(toDrop)) { ranges.get(ind - 1).setBegin(toDrop.next()); } else if (ranges.get(ind - 1).getEnd().previous().equals(toDrop)) { ranges.get(ind - 1).setEnd(toDrop); } else { TimePartition end = ranges.get(ind - 1).getEnd(); ranges.get(ind - 1).setEnd(toDrop); ranges.add(ind, toDrop.next().rangeUpto(end)); } if (ranges.get(ind - 1).isEmpty()) { ranges.remove(ind - 1); } return true; }
@Override public boolean drop(TimePartition toDrop) throws LensException { int ind = getStrictlyAfterIndex(toDrop); if (ind == 0) { return true; // nothing to do } if (ranges.get(ind - 1).getBegin().equals(toDrop)) { ranges.get(ind - 1).setBegin(toDrop.next()); } else if (ranges.get(ind - 1).getEnd().previous().equals(toDrop)) { ranges.get(ind - 1).setEnd(toDrop); } else { TimePartition end = ranges.get(ind - 1).getEnd(); ranges.get(ind - 1).setEnd(toDrop); ranges.add(ind, toDrop.next().rangeUpto(end)); } if (ranges.get(ind - 1).isEmpty()) { ranges.remove(ind - 1); } return true; }
@Override public boolean add(TimePartitionRange partitionRange) throws LensException { // Adding partition range to the timeline. Will have to find if any of the sub ranges // intersects. If yes, add only remaining sub ranges, else add the given range as a new sub range. int strictlyAfterIndex = getStrictlyAfterIndex(partitionRange.getBegin()); while (strictlyAfterIndex < ranges.size() && partitionRange.isValidAndNonEmpty()) { if (partitionRange.getEnd().before(ranges.get(strictlyAfterIndex).getBegin())) { // partition begin and end both are strictly before ranges[strictlyAfterIndex]. Add as new sub range. ranges.add(strictlyAfterIndex, partitionRange); partitionRange = partitionRange.getEnd().emptyRange(); break; } else { // begin is before ranges[strictlyAfterIndex], end is not. // extend ranges[strictlyAfterIndex] and add remaining range, if any. ranges.get(strictlyAfterIndex).setBegin(partitionRange.getBegin()); if (ranges.get(strictlyAfterIndex).getEnd().before(partitionRange.getEnd())) { partitionRange = ranges.get(strictlyAfterIndex).getEnd().rangeUpto(partitionRange.getEnd()); } else { // No remaining range, end was before ranges[strictlyAfterIndex].end partitionRange = ranges.get(strictlyAfterIndex).getEnd().emptyRange(); } strictlyAfterIndex++; } } if (strictlyAfterIndex == ranges.size() && partitionRange.isValidAndNonEmpty()) { ranges.add(partitionRange); } mergeRanges(); return true; }
@Override public boolean add(TimePartitionRange partitionRange) throws LensException { // Adding partition range to the timeline. Will have to find if any of the sub ranges // intersects. If yes, add only remaining sub ranges, else add the given range as a new sub range. int strictlyAfterIndex = getStrictlyAfterIndex(partitionRange.getBegin()); while (strictlyAfterIndex < ranges.size() && partitionRange.isValidAndNonEmpty()) { if (partitionRange.getEnd().before(ranges.get(strictlyAfterIndex).getBegin())) { // partition begin and end both are strictly before ranges[strictlyAfterIndex]. Add as new sub range. ranges.add(strictlyAfterIndex, partitionRange); partitionRange = partitionRange.getEnd().emptyRange(); break; } else { // begin is before ranges[strictlyAfterIndex], end is not. // extend ranges[strictlyAfterIndex] and add remaining range, if any. ranges.get(strictlyAfterIndex).setBegin(partitionRange.getBegin()); if (ranges.get(strictlyAfterIndex).getEnd().before(partitionRange.getEnd())) { partitionRange = ranges.get(strictlyAfterIndex).getEnd().rangeUpto(partitionRange.getEnd()); } else { // No remaining range, end was before ranges[strictlyAfterIndex].end partitionRange = ranges.get(strictlyAfterIndex).getEnd().emptyRange(); } strictlyAfterIndex++; } } if (strictlyAfterIndex == ranges.size() && partitionRange.isValidAndNonEmpty()) { ranges.add(partitionRange); } mergeRanges(); return true; }