TimeSeriesUtils { static String writeIndexName(Model model, long timeBucket) { final String modelName = model.getName(); if (model.isRecord() && model.isSuperDataset()) { return modelName + Const.LINE + compressTimeBucket(timeBucket / 1000000, SUPER_DATASET_DAY_STEP); } else if (model.isRecord()) { return modelName + Const.LINE + compressTimeBucket(timeBucket / 1000000, DAY_STEP); } else { switch (model.getDownsampling()) { case None: return modelName; case Hour: return modelName + Const.LINE + compressTimeBucket(timeBucket / 100, DAY_STEP); case Minute: return modelName + Const.LINE + compressTimeBucket(timeBucket / 10000, DAY_STEP); case Day: return modelName + Const.LINE + compressTimeBucket(timeBucket, DAY_STEP); case Second: return modelName + Const.LINE + compressTimeBucket(timeBucket / 1000000, DAY_STEP); default: throw new UnexpectedException("Unexpected down sampling value, " + model.getDownsampling()); } } }  static String latestWriteIndexName(Model model); static String[] superDatasetIndexNames(String indexName, long startSecondTB, long endSecondTB);  }
@Test public void testIndexRolling() { long secondTimeBucket = 2020_0809_1010_59L; long minuteTimeBucket = 2020_0809_1010L; Assert.assertEquals("superDatasetModel-20200809", writeIndexName(superDatasetModel, secondTimeBucket)); Assert.assertEquals("normalRecordModel-20200807", writeIndexName(normalRecordModel, secondTimeBucket)); Assert.assertEquals("normalMetricsModel-20200807", writeIndexName(normalMetricsModel, minuteTimeBucket)); secondTimeBucket += 1000000; minuteTimeBucket += 10000; Assert.assertEquals("superDatasetModel-20200810", writeIndexName(superDatasetModel, secondTimeBucket)); Assert.assertEquals("normalRecordModel-20200810", writeIndexName(normalRecordModel, secondTimeBucket)); Assert.assertEquals("normalMetricsModel-20200810", writeIndexName(normalMetricsModel, minuteTimeBucket)); }