/** * Add partition range to the timeline. Default implementation is to iterate over the range and add * each time partition belonging to the given range. Implementing classes can override. * * @param partitionRange * @return whether add was successful * @throws LensException */ boolean add(TimePartitionRange partitionRange) throws LensException { boolean ret = true; for (TimePartition part : partitionRange) { ret &= add(part); } return ret; }
/** * Add partition range to the timeline. Default implementation is to iterate over the range and add * each time partition belonging to the given range. Implementing classes can override. * * @param partitionRange * @return whether add was successful * @throws LensException */ boolean add(TimePartitionRange partitionRange) throws LensException { boolean ret = true; for (TimePartition part : partitionRange) { ret &= add(part); } return ret; }
/** * Add multiple partitions to timeline * * @param partitions * @return whether add was successful * @throws LensException */ public boolean add(@NonNull Collection<TimePartition> partitions) throws LensException { boolean result = true; for (TimePartition partition : partitions) { result &= add(partition); } // Can also return the failed to add items. return result; }
/** * Add multiple partitions to timeline * * @param partitions * @return whether add was successful * @throws LensException */ public boolean add(@NonNull Collection<TimePartition> partitions) throws LensException { boolean result = true; for (TimePartition partition : partitions) { result &= add(partition); } // Can also return the failed to add items. return result; }
/** update partition timeline cache for addition of time partition */ public void updateForAddition(String cubeTableName, String storageName, UpdatePeriod updatePeriod, Map<String, TreeSet<Date>> timePartSpec) throws HiveException, LensException { // fail fast. All part cols mentioned in all partitions should exist. for (String partCol : timePartSpec.keySet()) { getAndFailFast(cubeTableName, storageName, updatePeriod, partCol); } for (Map.Entry<String, TreeSet<Date>> entry : timePartSpec.entrySet()) { for (Date dt : entry.getValue()) { get(cubeTableName, storageName, updatePeriod, entry.getKey()).add(TimePartition.of(updatePeriod, dt)); } } }
/** update partition timeline cache for addition of time partition */ public void updateForAddition(String cubeTableName, String storageName, UpdatePeriod updatePeriod, Map<String, TreeSet<Date>> timePartSpec) throws HiveException, LensException { // fail fast. All part cols mentioned in all partitions should exist. for (String partCol : timePartSpec.keySet()) { getAndFailFast(cubeTableName, storageName, updatePeriod, partCol); } for (Map.Entry<String, TreeSet<Date>> entry : timePartSpec.entrySet()) { for (Date dt : entry.getValue()) { get(cubeTableName, storageName, updatePeriod, entry.getKey()).add(TimePartition.of(updatePeriod, dt)); } } }
/** * Commit all partitions that were added to batch addition queue. //TODO: improve batch addition implementation. * * @return true if all the partitions were added successfully, or no partitions needed to be added * @throws LensException */ public boolean commitBatchAdditions() throws LensException { if (getAll() == null) { return true; } log.info("initializing timeline from batch addition: {},{},{}", getStorageTableName(), getUpdatePeriod(), getPartCol()); boolean result = add(getAll()); all = null; log.info("initialized to: {}", this); return result; }
/** * Commit all partitions that were added to batch addition queue. //TODO: improve batch addition implementation. * * @return true if all the partitions were added successfully, or no partitions needed to be added * @throws LensException */ public boolean commitBatchAdditions() throws LensException { if (getAll() == null) { return true; } log.info("initializing timeline from batch addition: {},{},{}", getStorageTableName(), getUpdatePeriod(), getPartCol()); boolean result = add(getAll()); all = null; log.info("initialized to: {}", this); return result; }
addedPartitions.add(part); for (PartitionTimeline timeline : timelines) { timeline.add(part);
assertTrue(inst2.isEmpty()); assertTrue(inst1.add(TimePartition.of(period, TestTimePartition.NOW))); assertFalse(inst1.equals(inst2)); assertTrue(inst2.add(TimePartition.of(period, TestTimePartition.NOW))); assertTrue(inst1.isConsistent()); assertTrue(inst2.isConsistent()); assertTrue(inst1.add(TimePartition.of(period, TestTimePartition.timeAtDiff(TestTimePartition.NOW, period, i * 2))));