Skip to content

Commit f192a4d

Browse files
committed
Add debug collector usage
Signed-off-by: Asim Mahmood <[email protected]>
1 parent d0c2eac commit f192a4d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregator.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ class DateHistogramAggregator extends BucketsAggregator implements SizedBucketAg
115115
private final String fieldName;
116116
private final boolean fieldIndexSort;
117117

118+
// Collector usage tracking fields
119+
private int noOpCollectorsUsed;
120+
private int singleValuedCollectorsUsed;
121+
private int multiValuedCollectorsUsed;
122+
private int skipListCollectorsUsed;
123+
118124
DateHistogramAggregator(
119125
String name,
120126
AggregatorFactories factories,
@@ -215,6 +221,7 @@ protected boolean tryPrecomputeAggregationForLeaf(LeafReaderContext ctx) throws
215221
@Override
216222
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) throws IOException {
217223
if (valuesSource == null) {
224+
noOpCollectorsUsed++;
218225
return LeafBucketCollector.NO_OP_COLLECTOR;
219226
}
220227

@@ -228,12 +235,14 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCol
228235
if (skipper != null && singleton != null) {
229236
// TODO: add hard bounds support
230237
if (hardBounds == null && parent == null) {
238+
skipListCollectorsUsed++;
231239
return new HistogramSkiplistLeafCollector(singleton, skipper, preparedRounding, bucketOrds, sub, this);
232240
}
233241
}
234242

235243
if (singleton != null) {
236244
// Optimized path for single-valued fields
245+
singleValuedCollectorsUsed++;
237246
return new LeafBucketCollectorBase(sub, values) {
238247
@Override
239248
public void collect(int doc, long owningBucketOrd) throws IOException {
@@ -246,6 +255,7 @@ public void collect(int doc, long owningBucketOrd) throws IOException {
246255
}
247256

248257
// Original path for multi-valued fields
258+
multiValuedCollectorsUsed++;
249259
return new LeafBucketCollectorBase(sub, values) {
250260
@Override
251261
public void collect(int doc, long owningBucketOrd) throws IOException {
@@ -402,9 +412,13 @@ public void doClose() {
402412

403413
@Override
404414
public void collectDebugInfo(BiConsumer<String, Object> add) {
415+
super.collectDebugInfo(add);
405416
add.accept("total_buckets", bucketOrds.size());
406417
filterRewriteOptimizationContext.populateDebugInfo(add);
407-
// TODO: add skiplist, single and multi-value usage
418+
add.accept("no_op_collectors_used", noOpCollectorsUsed);
419+
add.accept("single_valued_collectors_used", singleValuedCollectorsUsed);
420+
add.accept("multi_valued_collectors_used", multiValuedCollectorsUsed);
421+
add.accept("skip_list_collectors_used", skipListCollectorsUsed);
408422
}
409423

410424
/**

server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ public void testSkiplistWithSingleValueDates() throws IOException {
293293
false,
294294
fieldType
295295
);
296-
System.out.println(histogram.getBuckets());
297296
assertEquals(3, histogram.getBuckets().size()); // 2015, 2016, 2017 (only type 2 docs)
298297

299298
assertEquals("2015-01-01T00:00:00.000Z", histogram.getBuckets().get(0).getKeyAsString());

0 commit comments

Comments
 (0)