Skip to content

Commit

Permalink
resolving merge conflicts
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 Oct 22, 2024
1 parent 5247065 commit fe8ed3e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,4 @@ public int compare(DateTimeUnitRounding unit1, DateTimeUnitRounding unit2) {
public static List<DateTimeUnitRounding> getSortedDateTimeUnits(List<DateTimeUnitRounding> dateTimeUnits) {
return dateTimeUnits.stream().sorted(new DateTimeUnitComparator()).collect(Collectors.toList());
}

public DocValuesType getDocValuesType() {
return DocValuesType.SORTED_NUMERIC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(field);
}

@Override
public DocValuesType getDocValuesType() {
return DocValuesType.SORTED_NUMERIC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ protected Codec getCodec() {
final Logger testLogger = LogManager.getLogger(StarTreeDocValuesFormatTests.class);

try {
createMapperService(getExpandedMapping());
mapperService = createMapperService(getMapping());
} catch (IOException e) {
throw new RuntimeException(e);
}
Codec codec = new Composite912Codec(Lucene912Codec.Mode.BEST_SPEED, mapperService, testLogger);
return codec;
}

private void createMapperService(XContentBuilder builder) throws IOException {
public static MapperService createMapperService(XContentBuilder builder) throws IOException {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
Expand All @@ -104,19 +104,20 @@ private void createMapperService(XContentBuilder builder) throws IOException {
.build();
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).putMapping(builder.toString()).build();
IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
mapperService = MapperTestUtils.newMapperServiceWithHelperAnalyzer(
MapperService mapperService = MapperTestUtils.newMapperServiceWithHelperAnalyzer(
new NamedXContentRegistry(ClusterModule.getNamedXWriteables()),
createTempDir(),
settings,
indicesModule,
"test"
);
mapperService.merge(indexMetadata, MapperService.MergeReason.INDEX_TEMPLATE);
return mapperService;
}

abstract XContentBuilder getExpandedMapping() throws IOException;
abstract XContentBuilder getMapping() throws IOException;

XContentBuilder topMapping(CheckedConsumer<XContentBuilder, IOException> buildFields) throws IOException {
public static XContentBuilder topMapping(CheckedConsumer<XContentBuilder, IOException> buildFields) throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject().startObject("_doc");
buildFields.accept(builder);
return builder.endObject().endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.opensearch.common.util.FeatureFlags.STAR_TREE_INDEX;
import static org.opensearch.index.compositeindex.CompositeIndexConstants.STAR_TREE_DOCS_COUNT;
import static org.opensearch.index.compositeindex.datacube.startree.StarTreeTestUtils.assertStarTreeDocuments;

Expand Down Expand Up @@ -244,7 +241,11 @@ public void testStarTreeDocValuesWithDeletions() throws IOException {
}

@Override
protected XContentBuilder getExpandedMapping() throws IOException {
protected XContentBuilder getMapping() throws IOException {
return getExpandedMapping();
}

public static XContentBuilder getExpandedMapping() throws IOException {
return topMapping(b -> {
b.startObject("composite");
b.startObject("startree");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public void testStarKeywordDocValuesWithMissingDocsInMixedSegments() throws IOEx
}

@Override
protected XContentBuilder getExpandedMapping() throws IOException {
protected XContentBuilder getMapping() throws IOException {
return topMapping(b -> {
b.startObject("composite");
b.startObject("startree");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public static StarTreeDocument getStarTreeDocument(

public static Double toAggregatorValueType(Long value, FieldValueConverter fieldValueConverter) {
try {
if (value == null) {
return 0.0;
}
return fieldValueConverter.toDoubleValue(value);
} catch (Exception e) {
throw new IllegalStateException("Cannot convert " + value + " to sortable aggregation type", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected Codec getCodec() {
final Logger testLogger = LogManager.getLogger(MetricAggregatorTests.class);
MapperService mapperService;
try {
mapperService = StarTreeDocValuesFormatTests.createMapperService(StarTreeDocValuesFormatTests.getExpandedMapping());
mapperService = StarTreeDocValuesFormatTests.createMapperService(StarTreeFilterTests.getExpandedMapping(1, false));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import java.util.List;
import java.util.Map;

import static org.opensearch.index.codec.composite912.datacube.startree.StarTreeDocValuesFormatTests.topMapping;
import static org.opensearch.index.codec.composite912.datacube.startree.AbstractStarTreeDVFormatTests.topMapping;

public class StarTreeFilterTests extends AggregatorTestCase {

Expand Down

0 comments on commit fe8ed3e

Please sign in to comment.