Skip to content

Commit ff50df0

Browse files
Refactoring
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
1 parent feab228 commit ff50df0

14 files changed

Lines changed: 349 additions & 122 deletions

File tree

server/src/main/java/org/apache/lucene/index/BaseCompositeFieldStarTreeBuilder.java renamed to server/src/main/java/org/apache/lucene/index/BaseSingleStarTreeBuilder.java

Lines changed: 66 additions & 87 deletions
Large diffs are not rendered by default.

server/src/main/java/org/opensearch/index/compositeindex/startree/aggregators/MetricTypeFieldPair.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public class MetricTypeFieldPair implements Comparable<MetricTypeFieldPair> {
2121
public static final String STAR = "*";
2222
public static final MetricTypeFieldPair COUNT_STAR = new MetricTypeFieldPair(MetricType.COUNT, STAR);
2323

24-
private final MetricType functionType;
24+
private final MetricType metricType;
2525
private final String field;
2626

2727
/**
2828
* Constructor for MetricTypeFieldPair
2929
*/
30-
public MetricTypeFieldPair(MetricType functionType, String field) {
31-
this.functionType = functionType;
32-
if (functionType == MetricType.COUNT) {
30+
public MetricTypeFieldPair(MetricType metricType, String field) {
31+
this.metricType = metricType;
32+
if (metricType == MetricType.COUNT) {
3333
this.field = STAR;
3434
} else {
3535
this.field = field;
@@ -39,8 +39,8 @@ public MetricTypeFieldPair(MetricType functionType, String field) {
3939
/**
4040
* @return Metric Type
4141
*/
42-
public MetricType getFunctionType() {
43-
return functionType;
42+
public MetricType getMetricType() {
43+
return metricType;
4444
}
4545

4646
/**
@@ -51,42 +51,42 @@ public String getField() {
5151
}
5252

5353
/**
54-
* @return field name with function type and field
54+
* @return field name with metric type and field
5555
*/
5656
public String toFieldName() {
57-
return toFieldName(functionType, field);
57+
return toFieldName(metricType, field);
5858
}
5959

6060
/**
61-
* Builds field name with function type and field
61+
* Builds field name with metric type and field
6262
*/
63-
public static String toFieldName(MetricType functionType, String field) {
64-
return functionType.getTypeName() + DELIMITER + field;
63+
public static String toFieldName(MetricType metricType, String field) {
64+
return metricType.getTypeName() + DELIMITER + field;
6565
}
6666

6767
/**
6868
* Builds MetricTypeFieldPair from field name
6969
*/
7070
public static MetricTypeFieldPair fromFieldName(String fieldName) {
7171
String[] parts = fieldName.split(DELIMITER, 2);
72-
return fromFunctionAndFieldName(parts[0], parts[1]);
72+
return fromMetricAndFieldName(parts[0], parts[1]);
7373
}
7474

7575
/**
76-
* Builds MetricTypeFieldPair from function and field name
76+
* Builds MetricTypeFieldPair from metric and field name
7777
*/
78-
private static MetricTypeFieldPair fromFunctionAndFieldName(String functionName, String fieldName) {
79-
MetricType functionType = MetricType.fromTypeName(functionName);
80-
if (functionType == MetricType.COUNT) {
78+
private static MetricTypeFieldPair fromMetricAndFieldName(String metricName, String fieldName) {
79+
MetricType metricType = MetricType.fromTypeName(metricName);
80+
if (metricType == MetricType.COUNT) {
8181
return COUNT_STAR;
8282
} else {
83-
return new MetricTypeFieldPair(functionType, fieldName);
83+
return new MetricTypeFieldPair(metricType, fieldName);
8484
}
8585
}
8686

8787
@Override
8888
public int hashCode() {
89-
return 31 * functionType.hashCode() + field.hashCode();
89+
return 31 * metricType.hashCode() + field.hashCode();
9090
}
9191

9292
@Override
@@ -96,7 +96,7 @@ public boolean equals(Object obj) {
9696
}
9797
if (obj instanceof MetricTypeFieldPair) {
9898
MetricTypeFieldPair anotherPair = (MetricTypeFieldPair) obj;
99-
return functionType == anotherPair.functionType && field.equals(anotherPair.field);
99+
return metricType == anotherPair.metricType && field.equals(anotherPair.field);
100100
}
101101
return false;
102102
}
@@ -109,7 +109,7 @@ public String toString() {
109109
@Override
110110
public int compareTo(MetricTypeFieldPair other) {
111111
return Comparator.comparing((MetricTypeFieldPair o) -> o.field)
112-
.thenComparing((MetricTypeFieldPair o) -> o.functionType)
112+
.thenComparing((MetricTypeFieldPair o) -> o.metricType)
113113
.compare(this, other);
114114
}
115115
}

server/src/main/java/org/opensearch/index/compositeindex/startree/aggregators/SumValueAggregator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.opensearch.index.compositeindex.startree.aggregators;
99

1010
import org.opensearch.index.compositeindex.MetricType;
11+
import org.opensearch.index.compositeindex.startree.data.DataType;
1112

1213
/**
1314
* Sum value aggregator for star tree

server/src/main/java/org/opensearch/index/compositeindex/startree/aggregators/ValueAggregator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.opensearch.index.compositeindex.startree.aggregators;
99

1010
import org.opensearch.index.compositeindex.MetricType;
11+
import org.opensearch.index.compositeindex.startree.data.DataType;
1112

1213
/**
1314
* A value aggregator that pre-aggregates on the input values for a specific type of aggregation.

server/src/main/java/org/opensearch/index/compositeindex/startree/aggregators/ValueAggregatorFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.opensearch.index.compositeindex.startree.aggregators;
99

1010
import org.opensearch.index.compositeindex.MetricType;
11+
import org.opensearch.index.compositeindex.startree.data.DataType;
1112

1213
/**
1314
* Value aggregator factory for a given aggregation type

server/src/main/java/org/opensearch/index/compositeindex/startree/builder/CompositeFieldWriter.java renamed to server/src/main/java/org/opensearch/index/compositeindex/startree/builder/SingleTreeBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package org.opensearch.index.compositeindex.startree.builder;
1010

11+
import org.opensearch.index.compositeindex.startree.data.StarTreeDocValues;
12+
1113
import java.io.Closeable;
1214
import java.io.IOException;
1315
import java.util.List;
@@ -16,7 +18,7 @@
1618
* A star-tree builder that builds a single star-tree.
1719
* @opensearch.experimental
1820
*/
19-
public interface CompositeFieldWriter extends Closeable {
21+
public interface SingleTreeBuilder extends Closeable {
2022

2123
/**
2224
* Builds the data structure for the given composite index config.

server/src/main/java/org/opensearch/index/compositeindex/startree/aggregators/DataType.java renamed to server/src/main/java/org/opensearch/index/compositeindex/startree/data/DataType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* this file be licensed under the Apache-2.0 license or a
66
* compatible open source license.
77
*/
8-
package org.opensearch.index.compositeindex.startree.aggregators;
8+
package org.opensearch.index.compositeindex.startree.data;
99

1010
/**
1111
* Data type of doc values

server/src/main/java/org/opensearch/index/compositeindex/startree/builder/StarTreeDocValues.java renamed to server/src/main/java/org/opensearch/index/compositeindex/startree/data/StarTreeDocValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* this file be licensed under the Apache-2.0 license or a
66
* compatible open source license.
77
*/
8-
package org.opensearch.index.compositeindex.startree.builder;
8+
package org.opensearch.index.compositeindex.startree.data;
99

1010
import org.apache.lucene.index.SortedNumericDocValues;
1111
import org.opensearch.index.compositeindex.startree.node.StarTree;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.index.compositeindex.startree.data;
10+
11+
import java.util.Arrays;
12+
13+
/**
14+
* Star tree document
15+
*/
16+
public class StarTreeDocument {
17+
public final long[] dimensions;
18+
public final Object[] metrics;
19+
20+
public StarTreeDocument(long[] dimensions, Object[] metrics) {
21+
this.dimensions = dimensions;
22+
this.metrics = metrics;
23+
}
24+
25+
@Override
26+
public String toString() {
27+
return Arrays.toString(dimensions) + " | " + Arrays.toString(metrics);
28+
}
29+
}

server/src/main/java/org/opensearch/index/compositeindex/startree/node/StarTreeNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/**
1414
* Class representing each node in star tree
15+
* The interface is implemented by build-mode based nodes
1516
* @opensearch.experimental
1617
*/
1718
public interface StarTreeNode {

0 commit comments

Comments
 (0)