return telemetry;
}
private void insertDataToCassandra(List<Object[]> existingData) throws Exception {
List<ResultSetFuture> resultSetFutures = new ArrayList<ResultSetFuture>();
Batch batch = QueryBuilder.batch();
int batchSize = 0;
//only need approximate TTL to speed up processing
//given that each batch is processed within seconds, getting the
//system time once per batch has minimal impact on the record retention
long creationTimeMillis;
long itemTTLSeconds;
long currentTimeMillis = System.currentTimeMillis();
long expectedTTLMillis = migrationTable.getTTLinMilliseconds();
for (Object[] rawMeasurement : existingData) {
creationTimeMillis = Long.parseLong(rawMeasurement[MigrationQuery.TIMESTAMP_INDEX].toString());
itemTTLSeconds = (expectedTTLMillis - currentTimeMillis + creationTimeMillis) / 1000l;
if (itemTTLSeconds > 0) {
int scheduleId = Integer.parseInt(rawMeasurement[MigrationQuery.SCHEDULE_INDEX].toString());
Date time = new Date(creationTimeMillis);
batch.add(QueryBuilder.insertInto(MetricsTable.AGGREGATE.toString())
.value("schedule_id", scheduleId)
.value("bucket", migrationTable.getMigrationBucket().toString())
.value("time", time)
.value("avg", Double.parseDouble(rawMeasurement[MigrationQuery.VALUE_INDEX].toString()))
.value("min", Double.parseDouble(rawMeasurement[MigrationQuery.MIN_VALUE_INDEX].toString()))