forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
c647863
commit b139000
Showing
11 changed files
with
267 additions
and
99 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
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
70 changes: 70 additions & 0 deletions
70
...pensearch/index/compositeindex/datacube/startree/aggregators/DocCountAggregatorTests.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,70 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* Unit tests for {@link DocCountAggregator}. | ||
*/ | ||
public class DocCountAggregatorTests extends AbstractValueAggregatorTests { | ||
|
||
private DocCountAggregator aggregator; | ||
|
||
public DocCountAggregatorTests(StarTreeNumericType starTreeNumericType) { | ||
super(starTreeNumericType); | ||
} | ||
|
||
public void testMergeAggregatedValueAndSegmentValue() { | ||
long randomLong = randomLong(); | ||
assertEquals(randomLong + 3L, (long) aggregator.mergeAggregatedValueAndSegmentValue(randomLong, 3L)); | ||
} | ||
|
||
public void testMergeAggregatedValues() { | ||
long randomLong1 = randomLong(); | ||
long randomLong2 = randomLong(); | ||
assertEquals(randomLong1 + randomLong2, (long) aggregator.mergeAggregatedValues(randomLong1, randomLong2)); | ||
assertEquals(randomLong1 + 1L, (long) aggregator.mergeAggregatedValues(randomLong1, null)); | ||
assertEquals(randomLong2 + 1L, (long) aggregator.mergeAggregatedValues(null, randomLong2)); | ||
} | ||
|
||
@Override | ||
public void testMergeAggregatedNullValueAndSegmentNullValue() { | ||
assertThrows(AssertionError.class, () -> aggregator.mergeAggregatedValueAndSegmentValue(null, null)); | ||
} | ||
|
||
@Override | ||
public void testMergeAggregatedNullValues() { | ||
assertEquals( | ||
(aggregator.getIdentityMetricValue() + aggregator.getIdentityMetricValue()), | ||
(long) aggregator.mergeAggregatedValues(null, null) | ||
); | ||
} | ||
|
||
public void testGetInitialAggregatedValue() { | ||
long randomLong = randomLong(); | ||
assertEquals(randomLong, (long) aggregator.getInitialAggregatedValue(randomLong)); | ||
} | ||
|
||
public void testToStarTreeNumericTypeValue() { | ||
long randomLong = randomLong(); | ||
assertEquals(randomLong, aggregator.toStarTreeNumericTypeValue(randomLong), 0.0); | ||
assertNull(aggregator.toStarTreeNumericTypeValue(null)); | ||
} | ||
|
||
public void testIdentityMetricValue() { | ||
assertEquals(1L, (long) aggregator.getIdentityMetricValue()); | ||
} | ||
|
||
@Override | ||
public ValueAggregator getValueAggregator(StarTreeNumericType starTreeNumericType) { | ||
aggregator = new DocCountAggregator(); | ||
return aggregator; | ||
} | ||
} |
Oops, something went wrong.