diff --git a/processing/src/test/java/io/druid/query/aggregation/AggregationTestHelper.java b/processing/src/test/java/io/druid/query/aggregation/AggregationTestHelper.java index 7c6c6c37a55..3f11d467566 100644 --- a/processing/src/test/java/io/druid/query/aggregation/AggregationTestHelper.java +++ b/processing/src/test/java/io/druid/query/aggregation/AggregationTestHelper.java @@ -314,22 +314,20 @@ public class AggregationTestHelper index = new OnheapIncrementalIndex(minTimestamp, gran, metrics, deserializeComplexMetrics, maxRowCount); while (rows.hasNext()) { Object row = rows.next(); - try { - if (row instanceof String && parser instanceof StringInputRowParser) { - //Note: this is required because StringInputRowParser is InputRowParser as opposed to - //InputRowsParser - index.add(((StringInputRowParser) parser).parse((String) row)); - } else { - index.add(parser.parse(row)); - } - } - catch (IndexSizeExceededException ex) { + if (!index.canAppendRow()) { File tmp = tempFolder.newFolder(); toMerge.add(tmp); indexMerger.persist(index, tmp, new IndexSpec()); index.close(); index = new OnheapIncrementalIndex(minTimestamp, gran, metrics, deserializeComplexMetrics, maxRowCount); } + if (row instanceof String && parser instanceof StringInputRowParser) { + //Note: this is required because StringInputRowParser is InputRowParser as opposed to + //InputRowsParser + index.add(((StringInputRowParser) parser).parse((String) row)); + } else { + index.add(parser.parse(row)); + } } if (toMerge.size() > 0) {