IntervalBuilder intervalBuilder = intervalBuilderLocator.lookup(columnType, groupStrategy);
if (intervalBuilder == null) throw new RuntimeException("Interval generator not supported.");
// No index => Build required
if (context.index == null) {
IntervalList intervalList = intervalBuilder.build(new InternalHandler(context), columnGroup);
return new DataSetGroupIndex(columnGroup, intervalList);
}
// Index match => Reuse it
DataSetGroupIndex groupIndex = context.index.getGroupIndex(columnGroup);
if (groupIndex != null) {
return groupIndex;
}
// No index match => Build required
chronometer.start();
IntervalList intervalList = intervalBuilder.build(new InternalHandler(context), columnGroup);
chronometer.stop();
// Index before return.
DataSetGroupIndex index = new DataSetGroupIndex(columnGroup, intervalList);
index.setBuildTime(chronometer.elapsedTime());