Skip to content

Commit a88663e

Browse files
committed
[Docs] Add detailed comments to GlobalOrdinalValuesSource collector
1 parent e522129 commit a88663e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

server/src/main/java/org/opensearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,15 @@ BytesRef toComparable(int slot) throws IOException {
165165

166166
@Override
167167
LeafBucketCollector getLeafCollector(LeafReaderContext context, LeafBucketCollector next) throws IOException {
168-
// Get the DocValues for this segment/leaf of the index
169168
final SortedSetDocValues dvs = docValuesFunc.apply(context);
170-
171-
// Initialize lookup table for ordinals if not already done
172169
if (lookup == null) {
173170
initLookup(dvs);
174171
}
175172

173+
// unwrapSingleton() returns non-null only if the field is single-valued
176174
final SortedDocValues singleton = DocValues.unwrapSingleton(dvs);
177175

176+
// Optimization path: Field is confirmed to be single-valued
178177
if (singleton != null) {
179178
return new LeafBucketCollector() {
180179
@Override

0 commit comments

Comments
 (0)