Skip to content

Commit

Permalink
resolving conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie committed Aug 24, 2024
1 parent 3b2e233 commit 7fb7314
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public void testUpdateIndexWhenMappingIsSame() {
assertEquals("numeric_dv", starTreeFieldType.getMetrics().get(0).getField());

// Assert default metrics
List<MetricStat> expectedMetrics = Arrays.asList(MetricStat.COUNT, MetricStat.SUM, MetricStat.AVG);
List<MetricStat> expectedMetrics = Arrays.asList(MetricStat.VALUE_COUNT, MetricStat.SUM, MetricStat.AVG);
assertEquals(expectedMetrics, starTreeFieldType.getMetrics().get(0).getMetrics());
assertEquals(10000, starTreeFieldType.getStarTreeConfig().maxLeafDocs());
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.apache.lucene.store.RandomAccessInput;
import org.opensearch.index.compositeindex.datacube.startree.fileformats.data.StarTreeDataWriter;
import org.opensearch.index.compositeindex.datacube.startree.fileformats.meta.StarTreeMetadata;
import static org.opensearch.index.compositeindex.CompositeIndexConstants.COMPOSITE_FIELD_MARKER;
import static org.opensearch.index.compositeindex.datacube.startree.fileformats.StarTreeWriter.VERSION_CURRENT;

import java.io.IOException;

Expand All @@ -28,15 +30,15 @@ public class StarTree {

public StarTree(IndexInput data, StarTreeMetadata starTreeMetadata) throws IOException {
long magicMarker = data.readLong();
// if (COMPOSITE_FIELD_MARKER != magicMarker) {
// logger.error("Invalid magic marker");
// throw new IOException("Invalid magic marker");
// }
if (COMPOSITE_FIELD_MARKER != magicMarker) {
logger.error("Invalid magic marker");
throw new IOException("Invalid magic marker");
}
int version = data.readInt();
// if (VERSION_CURRENT != version) {
// logger.error("Invalid star tree version");
// throw new IOException("Invalid version");
// }
if (VERSION_CURRENT != version) {
logger.error("Invalid star tree version");
throw new IOException("Invalid version");
}
numNodes = data.readInt(); // num nodes

RandomAccessInput in = data.randomAccessSlice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private XContentBuilder getExpandedMapping() throws IOException {
b.field("name", "field");
b.startArray("stats");
b.value("sum");
b.value("count");
b.value("value_count");
b.endArray();
b.endObject();
b.endArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public void testConstructor() {

public void testCountStarConstructor() {
MetricAggregatorInfo pair = new MetricAggregatorInfo(
MetricStat.COUNT,
MetricStat.VALUE_COUNT,
"anything",
"star_tree_field",
IndexNumericFieldData.NumericType.DOUBLE
);
assertEquals(MetricStat.COUNT, pair.getMetricStat());
assertEquals(MetricStat.VALUE_COUNT, pair.getMetricStat());
assertEquals("anything", pair.getField());
}

Expand Down Expand Up @@ -62,7 +62,7 @@ public void testEquals() {
assertEquals(pair1, pair2);
assertNotEquals(
pair1,
new MetricAggregatorInfo(MetricStat.COUNT, "column1", "star_tree_field", IndexNumericFieldData.NumericType.DOUBLE)
new MetricAggregatorInfo(MetricStat.VALUE_COUNT, "column1", "star_tree_field", IndexNumericFieldData.NumericType.DOUBLE)
);
assertNotEquals(
pair1,
Expand Down Expand Up @@ -100,7 +100,7 @@ public void testCompareTo() {
IndexNumericFieldData.NumericType.DOUBLE
);
MetricAggregatorInfo pair3 = new MetricAggregatorInfo(
MetricStat.COUNT,
MetricStat.VALUE_COUNT,
"column1",
"star_tree_field",
IndexNumericFieldData.NumericType.DOUBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void testGetValueAggregatorForMaxType() {
}

public void testGetValueAggregatorForCountType() {
ValueAggregator aggregator = ValueAggregatorFactory.getValueAggregator(MetricStat.COUNT, StarTreeNumericType.LONG);
ValueAggregator aggregator = ValueAggregatorFactory.getValueAggregator(MetricStat.VALUE_COUNT, StarTreeNumericType.LONG);
assertNotNull(aggregator);
assertEquals(CountValueAggregator.class, aggregator.getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void setup() throws IOException {
metrics = List.of(
new Metric("field2", List.of(MetricStat.SUM)),
new Metric("field4", List.of(MetricStat.SUM)),
new Metric("field6", List.of(MetricStat.COUNT)),
new Metric("field6", List.of(MetricStat.VALUE_COUNT)),
new Metric("field9", List.of(MetricStat.MIN)),
new Metric("field10", List.of(MetricStat.MAX)),
new Metric("_doc_count", List.of(MetricStat.DOC_COUNT))
Expand Down Expand Up @@ -2262,7 +2262,7 @@ private StarTreeField getStarTreeFieldWithMultipleMetrics() {
Dimension d1 = new NumericDimension("field1");
Dimension d2 = new NumericDimension("field3");
Metric m1 = new Metric("field2", List.of(MetricStat.SUM));
Metric m2 = new Metric("field2", List.of(MetricStat.COUNT));
Metric m2 = new Metric("field2", List.of(MetricStat.VALUE_COUNT));
List<Dimension> dims = List.of(d1, d2);
List<Metric> metrics = List.of(m1, m2);
StarTreeFieldConfiguration c = new StarTreeFieldConfiguration(10, new HashSet<>(), getBuildMode());
Expand Down Expand Up @@ -2637,7 +2637,7 @@ public void testMergeFlowNumSegmentsDocs() throws IOException {
List<Long> metricsList2 = List.of(5L, 6L, 7L, 8L, 9L);
List<Integer> metricsWithField2 = List.of(0, 1, 2, 3, 4);

StarTreeField sf = getStarTreeField(MetricStat.COUNT);
StarTreeField sf = getStarTreeField(MetricStat.VALUE_COUNT);
StarTreeValues starTreeValues = getStarTreeValues(
getSortedNumericMock(dimList, docsWithField),
getSortedNumericMock(dimList2, docsWithField2),
Expand Down

0 comments on commit 7fb7314

Please sign in to comment.