liran-funaro commented on a change in pull request #10593:
URL: https://github.com/apache/druid/pull/10593#discussion_r533155662
##########
File path:
benchmarks/src/test/java/org/apache/druid/benchmark/FilteredAggregatorBenchmark.java
##########
@@ -205,30 +184,106 @@ public void setup() throws IOException
GeneratorSchemaInfo basicSchema =
GeneratorBasicSchemas.SCHEMA_MAP.get("basic");
QuerySegmentSpec intervalSpec = new
MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));
- List<AggregatorFactory> queryAggs = new ArrayList<>();
- queryAggs.add(filteredMetrics[0]);
+ List<AggregatorFactory> queryAggs =
Collections.singletonList(filteredMetric);
query = Druids.newTimeseriesQueryBuilder()
.dataSource("blah")
.granularity(Granularities.ALL)
.intervals(intervalSpec)
.aggregators(queryAggs)
- .descending(false)
+ .descending(descending)
.build();
}
- @TearDown
- public void tearDown() throws IOException
+ @State(Scope.Benchmark)
+ public static class IncrementalIndexState
+ {
+ @Param({"onheap", "offheap"})
+ private String indexType;
+
+ IncrementalIndex<?> incIndex;
+
+ @Setup
+ public void setup(FilteredAggregatorBenchmark global) throws
JsonProcessingException
+ {
+ global.appendableIndexSpec =
IncrementalIndexCreator.parseIndexType(indexType);
+ incIndex = global.makeIncIndex(global.schemaInfo.getAggsArray());
+ global.generator.addToIndex(incIndex, global.rowsPerSegment);
+ }
+
+ @TearDown
+ public void tearDown()
+ {
+ incIndex.close();
+ }
+ }
+
+ @State(Scope.Benchmark)
+ public static class IncrementalIndexIngestState
{
- FileUtils.deleteDirectory(tmpDir);
+ @Param({"onheap", "offheap"})
+ private String indexType;
+
+ IncrementalIndex<?> incIndex;
+ List<InputRow> inputRows;
+
+ @Setup(Level.Invocation)
+ public void setup(FilteredAggregatorBenchmark global) throws
JsonProcessingException
+ {
+ global.appendableIndexSpec =
IncrementalIndexCreator.parseIndexType(indexType);
+ inputRows = global.generator.toList(global.rowsPerSegment);
+ incIndex = global.makeIncIndex(new
AggregatorFactory[]{global.filteredMetric});
+ }
+
+ @TearDown(Level.Invocation)
+ public void tearDown()
+ {
+ incIndex.close();
+ }
+ }
+
+ @State(Scope.Benchmark)
+ public static class QueryableIndexState
+ {
+ private File qIndexesDir;
+ private QueryableIndex qIndex;
+
+ @Setup
+ public void setup(FilteredAggregatorBenchmark global) throws IOException
+ {
+ global.appendableIndexSpec = new OnheapIncrementalIndex.Spec();
+
+ IncrementalIndex<?> incIndex =
global.makeIncIndex(global.schemaInfo.getAggsArray());
+ global.generator.addToIndex(incIndex, global.rowsPerSegment);
+
+ qIndexesDir = FileUtils.createTempDir();
+ log.info("Using temp dir: " + qIndexesDir.getAbsolutePath());
+
+ File indexFile = INDEX_MERGER_V9.persist(
+ incIndex,
+ qIndexesDir,
+ new IndexSpec(),
+ null
+ );
+ incIndex.close();
+
+ qIndex = INDEX_IO.loadIndex(indexFile);
+ }
+
+ @TearDown
+ public void tearDown()
+ {
+ qIndex.close();
Review comment:
I'm not sure. But if setup fails, this might be an issue. Added a null
check just to be safe.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]