Skip to content

Commit

Permalink
adding startreenode related tests
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
  • Loading branch information
bharath-techie committed Jul 19, 2024
1 parent c55460f commit 21f9ff0
Show file tree
Hide file tree
Showing 3 changed files with 537 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ private void mergeStarTreeFields(MergeState mergeState) throws IOException {
}
}

Check warning on line 196 in server/src/main/java/org/opensearch/index/codec/composite/Composite99DocValuesWriter.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/codec/composite/Composite99DocValuesWriter.java#L196

Added line #L196 was not covered by tests
}
final StarTreesBuilder starTreesBuilder = new StarTreesBuilder(state, mapperService);
starTreesBuilder.buildDuringMerge(starTreeSubsPerField);
try (StarTreesBuilder starTreesBuilder = new StarTreesBuilder(state, mapperService)) {
starTreesBuilder.buildDuringMerge(starTreeSubsPerField);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected BaseStarTreeBuilder(StarTreeField starTreeField, SegmentWriteState sta
public List<MetricAggregatorInfo> generateMetricAggregatorInfos(MapperService mapperService) {
List<MetricAggregatorInfo> metricAggregatorInfos = new ArrayList<>();
for (Metric metric : this.starTreeField.getMetrics()) {
for (MetricStat metricType : metric.getMetrics()) {
for (MetricStat metricStat : metric.getMetrics()) {
IndexNumericFieldData.NumericType numericType;
Mapper fieldMapper = mapperService.documentMapper().mappers().getMapper(metric.getField());
if (fieldMapper instanceof NumberFieldMapper) {
Expand All @@ -131,7 +131,7 @@ public List<MetricAggregatorInfo> generateMetricAggregatorInfos(MapperService ma
}

MetricAggregatorInfo metricAggregatorInfo = new MetricAggregatorInfo(
metricType,
metricStat,
metric.getField(),
starTreeField.getName(),
numericType
Expand Down Expand Up @@ -457,13 +457,13 @@ public List<SequentialDocValuesIterator> getMetricReaders(SegmentWriteState stat
throws IOException {
List<SequentialDocValuesIterator> metricReaders = new ArrayList<>();
for (Metric metric : this.starTreeField.getMetrics()) {
for (MetricStat metricType : metric.getMetrics()) {
for (MetricStat metricStat : metric.getMetrics()) {
FieldInfo metricFieldInfo = state.fieldInfos.fieldInfo(metric.getField());
if (metricFieldInfo == null) {
metricFieldInfo = getFieldInfo(metric.getField());
}
// TODO
// if (metricType != MetricStat.COUNT) {
// if (metricStat != MetricStat.COUNT) {
// Need not initialize the metric reader for COUNT metric type
SequentialDocValuesIterator metricReader = new SequentialDocValuesIterator(
fieldProducerMap.get(metricFieldInfo.name).getSortedNumeric(metricFieldInfo)
Expand Down Expand Up @@ -516,6 +516,10 @@ void build(Iterator<StarTreeDocument> starTreeDocumentIterator) throws IOExcepti

}

TreeNode getRootNode() {
return rootNode;

Check warning on line 520 in server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java#L520

Added line #L520 was not covered by tests
}

/**
* Adds a document to star-tree
*
Expand Down
Loading

0 comments on commit 21f9ff0

Please sign in to comment.