for (Row row : rows) {
permits.acquire();
int scheduleId = row.getInt(0);
BoundStatement statement = updateCacheIndex.bind(ImmutableSet.of(scheduleId), bucket.text(), day,
CACHE_INDEX_PARTITION, timeSlice, startId(scheduleId), insertTimeSlice);
ResultSetFuture future = session.executeAsync(statement);
Futures.addCallback(future, new CacheIndexUpdatedCallback(bucket, scheduleId, timeSlice, updatesFinished),
tasks);
}
updatesFinished.await();