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: Sarthak Aggarwal <[email protected]>
- Loading branch information
1 parent
51a4a3f
commit dd3a350
Showing
10 changed files
with
529 additions
and
202 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
63 changes: 63 additions & 0 deletions
63
...arch/index/compositeindex/datacube/startree/aggregators/AbstractValueAggregatorTests.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.MetricStat; | ||
import org.opensearch.index.compositeindex.datacube.startree.aggregators.numerictype.StarTreeNumericType; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
import org.junit.Before; | ||
|
||
public abstract class AbstractValueAggregatorTests extends OpenSearchTestCase { | ||
|
||
private ValueAggregator aggregator; | ||
|
||
@Before | ||
public void setup() { | ||
aggregator = getValueAggregator(); | ||
} | ||
|
||
public abstract ValueAggregator getValueAggregator(); | ||
|
||
public abstract MetricStat getMetricStat(); | ||
|
||
public abstract StarTreeNumericType getValueAggregatorType(); | ||
|
||
public void testGetAggregationType() { | ||
assertEquals(getMetricStat().getTypeName(), aggregator.getAggregationType().getTypeName()); | ||
} | ||
|
||
public void testGetAggregatedValueType() { | ||
assertEquals(getValueAggregatorType(), aggregator.getAggregatedValueType()); | ||
} | ||
|
||
public void testGetInitialAggregatedValueForSegmentDocNullValue() { | ||
assertEquals(aggregator.getIdentityMetricValue(), aggregator.getInitialAggregatedValueForSegmentDocValue(null)); | ||
} | ||
|
||
public void testMergeAggregatedNullValueAndSegmentNullValue() { | ||
assertEquals(aggregator.getIdentityMetricValue(), aggregator.mergeAggregatedValueAndSegmentValue(null, null)); | ||
} | ||
|
||
public void testMergeAggregatedNullValues() { | ||
assertEquals(aggregator.getIdentityMetricValue(), aggregator.mergeAggregatedValues(null, null)); | ||
} | ||
|
||
public void testGetInitialAggregatedNullValue() { | ||
assertEquals(aggregator.getIdentityMetricValue(), aggregator.getInitialAggregatedValue(null)); | ||
} | ||
|
||
public void testGetInitialAggregatedValueForSegmentDocValue() { | ||
Long randomLong = randomLong(); | ||
if (aggregator instanceof CountValueAggregator) { | ||
assertEquals(CountValueAggregator.DEFAULT_INITIAL_VALUE, aggregator.getInitialAggregatedValueForSegmentDocValue(randomLong())); | ||
} else { | ||
assertEquals(randomLong.doubleValue(), aggregator.getInitialAggregatedValueForSegmentDocValue(randomLong)); | ||
} | ||
} | ||
} |
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.