@Test public void testGetWatermark() { ZonedDateTime time = ZonedDateTime.of(2019, 12, 1, 18, 16, 0, 0, zone); Assert.assertEquals(CompactionWatermarkChecker.getWatermarkTimeMillis(time, TimeIterator.Granularity.MINUTE), 1575252959999L); Assert.assertEquals(CompactionWatermarkChecker.getWatermarkTimeMillis(time, TimeIterator.Granularity.HOUR), 1575251999999L); Assert.assertEquals(CompactionWatermarkChecker.getWatermarkTimeMillis(time, TimeIterator.Granularity.DAY), 1575187199999L); Assert.assertEquals(CompactionWatermarkChecker.getWatermarkTimeMillis(time, TimeIterator.Granularity.MONTH), 1575187199999L); }
@VisibleForTesting static long getWatermarkTimeMillis(ZonedDateTime compactionTime, TimeIterator.Granularity granularity) { ZonedDateTime startOfMinute = compactionTime.withSecond(0).with(ChronoField.MILLI_OF_SECOND, 0); ZonedDateTime startOfTimeGranularity = startOfMinute; switch (granularity) { case MINUTE: break; case HOUR: startOfTimeGranularity = startOfMinute.withMinute(0); break; case DAY: startOfTimeGranularity = startOfMinute.withHour(0).withMinute(0); break; case MONTH: startOfTimeGranularity = startOfMinute.withDayOfMonth(1).withHour(0).withMinute(0); break; } return startOfTimeGranularity.minus(1, ChronoUnit.MILLIS).toInstant().toEpochMilli(); }
CompactionWatermarkChecker extends CompactionAuditCountVerifier { @VisibleForTesting static long getWatermarkTimeMillis(ZonedDateTime compactionTime, TimeIterator.Granularity granularity) { ZonedDateTime startOfMinute = compactionTime.withSecond(0).with(ChronoField.MILLI_OF_SECOND, 0); ZonedDateTime startOfTimeGranularity = startOfMinute; switch (granularity) { case MINUTE: break; case HOUR: startOfTimeGranularity = startOfMinute.withMinute(0); break; case DAY: startOfTimeGranularity = startOfMinute.withHour(0).withMinute(0); break; case MONTH: startOfTimeGranularity = startOfMinute.withDayOfMonth(1).withHour(0).withMinute(0); break; } return startOfTimeGranularity.minus(1, ChronoUnit.MILLIS).toInstant().toEpochMilli(); } }
CompactionWatermarkChecker extends CompactionAuditCountVerifier { @VisibleForTesting static long getWatermarkTimeMillis(ZonedDateTime compactionTime, TimeIterator.Granularity granularity) { ZonedDateTime startOfMinute = compactionTime.withSecond(0).with(ChronoField.MILLI_OF_SECOND, 0); ZonedDateTime startOfTimeGranularity = startOfMinute; switch (granularity) { case MINUTE: break; case HOUR: startOfTimeGranularity = startOfMinute.withMinute(0); break; case DAY: startOfTimeGranularity = startOfMinute.withHour(0).withMinute(0); break; case MONTH: startOfTimeGranularity = startOfMinute.withDayOfMonth(1).withHour(0).withMinute(0); break; } return startOfTimeGranularity.minus(1, ChronoUnit.MILLIS).toInstant().toEpochMilli(); } CompactionWatermarkChecker(State state); }
CompactionWatermarkChecker extends CompactionAuditCountVerifier { @VisibleForTesting static long getWatermarkTimeMillis(ZonedDateTime compactionTime, TimeIterator.Granularity granularity) { ZonedDateTime startOfMinute = compactionTime.withSecond(0).with(ChronoField.MILLI_OF_SECOND, 0); ZonedDateTime startOfTimeGranularity = startOfMinute; switch (granularity) { case MINUTE: break; case HOUR: startOfTimeGranularity = startOfMinute.withMinute(0); break; case DAY: startOfTimeGranularity = startOfMinute.withHour(0).withMinute(0); break; case MONTH: startOfTimeGranularity = startOfMinute.withDayOfMonth(1).withHour(0).withMinute(0); break; } return startOfTimeGranularity.minus(1, ChronoUnit.MILLIS).toInstant().toEpochMilli(); } CompactionWatermarkChecker(State state); @Override Result verify(FileSystemDataset dataset); }
CompactionWatermarkChecker extends CompactionAuditCountVerifier { @VisibleForTesting static long getWatermarkTimeMillis(ZonedDateTime compactionTime, TimeIterator.Granularity granularity) { ZonedDateTime startOfMinute = compactionTime.withSecond(0).with(ChronoField.MILLI_OF_SECOND, 0); ZonedDateTime startOfTimeGranularity = startOfMinute; switch (granularity) { case MINUTE: break; case HOUR: startOfTimeGranularity = startOfMinute.withMinute(0); break; case DAY: startOfTimeGranularity = startOfMinute.withHour(0).withMinute(0); break; case MONTH: startOfTimeGranularity = startOfMinute.withDayOfMonth(1).withHour(0).withMinute(0); break; } return startOfTimeGranularity.minus(1, ChronoUnit.MILLIS).toInstant().toEpochMilli(); } CompactionWatermarkChecker(State state); @Override Result verify(FileSystemDataset dataset); static final String TIME_FORMAT; static final String COMPACTION_WATERMARK; static final String COMPLETION_COMPACTION_WATERMARK; }