Fix persist of empty indexes in index generator job

This commit is contained in:
fjy 2013-08-22 10:16:43 -07:00
parent 4102dbd1e0
commit 778fd0f10e
2 changed files with 22 additions and 16 deletions

View File

@ -121,6 +121,10 @@ public class IndexMerger
final IncrementalIndex index, final Interval dataInterval, File outDir, ProgressIndicator progress
) throws IOException
{
if (index.isEmpty()) {
throw new IAE("Trying to persist an empty index!");
}
final long firstTimestamp = index.getMinTime().getMillis();
final long lastTimestamp = index.getMaxTime().getMillis();
if (!(dataInterval.contains(firstTimestamp) && dataInterval.contains(lastTimestamp))) {

View File

@ -321,7 +321,7 @@ public class IndexGeneratorJob implements Jobby
List<QueryableIndex> indexes = Lists.newArrayListWithCapacity(indexCount);
final File mergedBase;
if (toMerge.size() == 0) {
if (toMerge.size() == 0 && !index.isEmpty()) {
mergedBase = new File(baseFlushFile, "merged");
IndexMerger.persist(
index, interval, mergedBase, new IndexMerger.ProgressIndicator()
@ -334,6 +334,7 @@ public class IndexGeneratorJob implements Jobby
}
);
} else {
if (!index.isEmpty()) {
final File finalFile = new File(baseFlushFile, "final");
IndexMerger.persist(
index, interval, finalFile, new IndexMerger.ProgressIndicator()
@ -346,6 +347,7 @@ public class IndexGeneratorJob implements Jobby
}
);
toMerge.add(finalFile);
}
for (File file : toMerge) {
indexes.add(IndexIO.loadIndex(file));