Skip to content

Commit d93f589

Browse files
committed
Remove redundant comments from GlobalOrdinalValuesSource
Signed-off-by: shreyah963 <[email protected]>
1 parent c22e32a commit d93f589

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,35 +177,33 @@ LeafBucketCollector getLeafCollector(LeafReaderContext context, LeafBucketCollec
177177
// unwrapSingleton() returns non-null only if the field is single-valued
178178
final SortedDocValues singleton = DocValues.unwrapSingleton(dvs);
179179

180-
// Optimization path: Field is confirmed to be single-valued
180+
// Direct ordinal access for single-valued fields
181181
if (singleton != null) {
182182
return new LeafBucketCollector() {
183183
@Override
184184
public void collect(int doc, long bucket) throws IOException {
185-
if (singleton.advanceExact(doc)) { // If document has a value
186-
currentValue = singleton.ordValue(); // Get ordinal directly
187-
next.collect(doc, bucket); // Collect into bucket
188-
} else if (missingBucket) { // Handle missing value case
189-
currentValue = -1; // Use -1 for missing
185+
if (singleton.advanceExact(doc)) {
186+
currentValue = singleton.ordValue();
187+
next.collect(doc, bucket);
188+
} else if (missingBucket) {
189+
currentValue = -1;
190190
next.collect(doc, bucket);
191191
}
192192
}
193193
};
194194
}
195195

196-
// Non-optimized collector for multi-valued fields
197196
return new LeafBucketCollector() {
198197
@Override
199198
public void collect(int doc, long bucket) throws IOException {
200-
if (dvs.advanceExact(doc)) { // If document has values
199+
if (dvs.advanceExact(doc)) {
201200
long ord;
202-
int count = dvs.docValueCount(); // Get number of values
203-
// Loop through all values in the document
201+
int count = dvs.docValueCount();
204202
while ((count-- > 0) && (ord = dvs.nextOrd()) != NO_MORE_DOCS) {
205-
currentValue = ord; // Store current ordinal
206-
next.collect(doc, bucket); // Collect each value
203+
currentValue = ord;
204+
next.collect(doc, bucket);
207205
}
208-
} else if (missingBucket) { // Handle missing values
206+
} else if (missingBucket) {
209207
currentValue = -1;
210208
next.collect(doc, bucket);
211209
}

0 commit comments

Comments
 (0)