-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doc count field changes in star tree
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
- Loading branch information
1 parent
b316279
commit c647863
Showing
12 changed files
with
405 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...org/opensearch/index/compositeindex/datacube/startree/aggregators/DocCountAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.compositeindex.datacube.startree.aggregators; | ||
|
||
import org.opensearch.index.compositeindex.datacube.startree.aggregators.numerictype.StarTreeNumericType; | ||
|
||
/** | ||
* Aggregator to handle '_doc_count' field | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public class DocCountAggregator implements ValueAggregator<Long> { | ||
|
||
private static final StarTreeNumericType VALUE_AGGREGATOR_TYPE = StarTreeNumericType.LONG; | ||
|
||
public DocCountAggregator(StarTreeNumericType starTreeNumericType) {} | ||
|
||
@Override | ||
public StarTreeNumericType getAggregatedValueType() { | ||
return VALUE_AGGREGATOR_TYPE; | ||
} | ||
|
||
@Override | ||
public Long getInitialAggregatedValueForSegmentDocValue(Long segmentDocValue) { | ||
if (segmentDocValue == null) { | ||
return getIdentityMetricValue(); | ||
} | ||
return segmentDocValue; | ||
} | ||
|
||
@Override | ||
public Long mergeAggregatedValueAndSegmentValue(Long value, Long segmentDocValue) { | ||
assert value != null; | ||
return mergeAggregatedValues(value, segmentDocValue); | ||
} | ||
|
||
@Override | ||
public Long mergeAggregatedValues(Long value, Long aggregatedValue) { | ||
if (value == null) { | ||
value = getIdentityMetricValue(); | ||
} | ||
if (aggregatedValue == null) { | ||
aggregatedValue = getIdentityMetricValue(); | ||
} | ||
return value + aggregatedValue; | ||
} | ||
|
||
@Override | ||
public Long toStarTreeNumericTypeValue(Long value) { | ||
return value; | ||
} | ||
|
||
@Override | ||
public Long getIdentityMetricValue() { | ||
return 1L; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.