Skip to content

Commit c0ec6fd

Browse files
Revert "Fix compilation."
This reverts commit f204922. Signed-off-by: Yury-Fridlyand <[email protected]>
1 parent a310b4f commit c0ec6fd

File tree

10 files changed

+35
-56
lines changed

10 files changed

+35
-56
lines changed

opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/ADOperator.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ public boolean hasNext() {
9292
@Override
9393
public ExprValue next() {
9494
if (inputRowIter == null || !inputRowIter.hasNext()) {
95-
/*
9695
inputDataFrame = inputDataFramesIter.next().getLeft();
9796
inputRowIter = inputDataFrame.iterator();
9897
predictionResult = predictionResultIter.next();
9998
resultRowIter = predictionResult.getPredictionResult().iterator();
100-
*/
10199
}
102100
return buildResult(inputRowIter, inputDataFrame, predictionResult, resultRowIter);
103101
}
@@ -127,9 +125,7 @@ public List<PhysicalPlan> getChild() {
127125
protected MLAlgoParams convertArgumentToMLParameter(Map<String, Literal> arguments) {
128126
if (arguments.get(TIME_FIELD) == null) {
129127
rcfType = FunctionName.BATCH_RCF;
130-
return null;
131-
/*
132-
BatchRCFParams.builder()
128+
return BatchRCFParams.builder()
133129
.numberOfTrees(arguments.containsKey(NUMBER_OF_TREES)
134130
? ((Integer) arguments.get(NUMBER_OF_TREES).getValue())
135131
: null)
@@ -146,12 +142,9 @@ protected MLAlgoParams convertArgumentToMLParameter(Map<String, Literal> argumen
146142
? ((Double) arguments.get(ANOMALY_SCORE_THRESHOLD).getValue())
147143
: null)
148144
.build();
149-
*/
150145
}
151146
rcfType = FunctionName.FIT_RCF;
152-
return null;
153-
/*
154-
FitRCFParams.builder()
147+
return FitRCFParams.builder()
155148
.numberOfTrees(arguments.containsKey(NUMBER_OF_TREES)
156149
? ((Integer) arguments.get(NUMBER_OF_TREES).getValue())
157150
: null)
@@ -180,7 +173,6 @@ protected MLAlgoParams convertArgumentToMLParameter(Map<String, Literal> argumen
180173
? ((String) arguments.get(TIME_ZONE).getValue())
181174
: null)
182175
.build();
183-
*/
184176
}
185177

186178
}

opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public void open() {
6060
getMLPredictionResult(FunctionName.valueOf(algorithm.toUpperCase()),
6161
mlAlgoParams, inputDataFrame, nodeClient);
6262

63-
Iterator<Row> inputRowIter = Collections.emptyIterator();//inputDataFrame.iterator();
64-
Iterator<Row> resultRowIter = Collections.emptyIterator();//predictionResult.getPredictionResult().iterator();
63+
Iterator<Row> inputRowIter = inputDataFrame.iterator();
64+
Iterator<Row> resultRowIter = predictionResult.getPredictionResult().iterator();
6565
iterator = new Iterator<ExprValue>() {
6666
@Override
6767
public boolean hasNext() {
@@ -99,9 +99,7 @@ protected MLAlgoParams convertArgumentToMLParameter(Map<String, Literal> argumen
9999
String algorithm) {
100100
switch (FunctionName.valueOf(algorithm.toUpperCase())) {
101101
case KMEANS:
102-
return null;
103-
/*
104-
KMeansParams.builder()
102+
return KMeansParams.builder()
105103
.centroids(arguments.containsKey(CENTROIDS)
106104
? ((Integer) arguments.get(CENTROIDS).getValue())
107105
: null)
@@ -115,7 +113,6 @@ protected MLAlgoParams convertArgumentToMLParameter(Map<String, Literal> argumen
115113
: null)
116114
: null)
117115
.build();
118-
*/
119116
default:
120117
// TODO: update available algorithms in the message when adding a new case
121118
throw new IllegalArgumentException(

opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorActions.java

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ protected List<Pair<DataFrame, DataFrame>> generateCategorizedInputDataset(Physi
104104
protected Map<String, ExprValue> convertRowIntoExprValue(ColumnMeta[] columnMetas, Row row) {
105105
ImmutableMap.Builder<String, ExprValue> resultBuilder = new ImmutableMap.Builder<>();
106106
for (int i = 0; i < columnMetas.length; i++) {
107-
ColumnValue columnValue = null;//row.getValue(i);
108-
String resultKeyName = null;//columnMetas[i].getName();
107+
ColumnValue columnValue = row.getValue(i);
108+
String resultKeyName = columnMetas[i].getName();
109109
populateResultBuilder(columnValue, resultKeyName, resultBuilder);
110110
}
111111
return resultBuilder.build();
@@ -120,7 +120,6 @@ protected Map<String, ExprValue> convertRowIntoExprValue(ColumnMeta[] columnMeta
120120
protected void populateResultBuilder(ColumnValue columnValue,
121121
String resultKeyName,
122122
ImmutableMap.Builder<String, ExprValue> resultBuilder) {
123-
/*
124123
switch (columnValue.columnType()) {
125124
case INTEGER:
126125
resultBuilder.put(resultKeyName, new ExprIntegerValue(columnValue.intValue()));
@@ -145,7 +144,7 @@ protected void populateResultBuilder(ColumnValue columnValue,
145144
break;
146145
default:
147146
break;
148-
}*/
147+
}
149148
}
150149

151150
/**
@@ -160,8 +159,8 @@ protected Map<String, ExprValue> convertResultRowIntoExprValue(ColumnMeta[] colu
160159
Map<String, ExprValue> schema) {
161160
ImmutableMap.Builder<String, ExprValue> resultBuilder = new ImmutableMap.Builder<>();
162161
for (int i = 0; i < columnMetas.length; i++) {
163-
ColumnValue columnValue = null;//row.getValue(i);
164-
String resultKeyName = "";//columnMetas[i].getName();
162+
ColumnValue columnValue = row.getValue(i);
163+
String resultKeyName = columnMetas[i].getName();
165164
// change key name to avoid duplicate key issue in result map
166165
// only value will be shown in the final returned result
167166
if (schema.containsKey(resultKeyName)) {
@@ -186,13 +185,13 @@ protected ExprTupleValue buildResult(Iterator<Row> inputRowIter,
186185
MLPredictionOutput predictionResult,
187186
Iterator<Row> resultRowIter) {
188187
ImmutableMap.Builder<String, ExprValue> resultSchemaBuilder = new ImmutableMap.Builder<>();
189-
//resultSchemaBuilder.putAll(convertRowIntoExprValue(inputDataFrame.columnMetas(),
190-
// inputRowIter.next()));
188+
resultSchemaBuilder.putAll(convertRowIntoExprValue(inputDataFrame.columnMetas(),
189+
inputRowIter.next()));
191190
Map<String, ExprValue> resultSchema = resultSchemaBuilder.build();
192191
ImmutableMap.Builder<String, ExprValue> resultBuilder = new ImmutableMap.Builder<>();
193192
resultBuilder.putAll(convertResultRowIntoExprValue(
194-
null,//predictionResult.getPredictionResult().columnMetas(),
195-
null,//resultRowIter.next(),
193+
predictionResult.getPredictionResult().columnMetas(),
194+
resultRowIter.next(),
196195
resultSchema));
197196
resultBuilder.putAll(resultSchema);
198197
return ExprTupleValue.fromExprValueMap(resultBuilder.build());
@@ -210,19 +209,17 @@ protected MLPredictionOutput getMLPredictionResult(FunctionName functionName,
210209
MLAlgoParams mlAlgoParams,
211210
DataFrame inputDataFrame,
212211
NodeClient nodeClient) {
213-
/*
214212
MLInput mlinput = MLInput.builder()
215213
.algorithm(functionName)
216214
.parameters(mlAlgoParams)
217215
.inputDataset(new DataFrameInputDataset(inputDataFrame))
218216
.build();
219-
*/
217+
220218
MachineLearningNodeClient machineLearningClient =
221219
MLClient.getMLClient(nodeClient);
222220

223221
return (MLPredictionOutput) machineLearningClient
224-
//.trainAndPredict(mlinput)
225-
.trainAndPredict(null)
222+
.trainAndPredict(mlinput)
226223
.actionGet(30, TimeUnit.SECONDS);
227224
}
228225

@@ -236,21 +233,19 @@ protected MLPredictionOutput getMLPredictionResult(FunctionName functionName,
236233
protected MLOutput getMLOutput(DataFrame inputDataFrame,
237234
Map<String, Object> arguments,
238235
NodeClient nodeClient) {
239-
/*
240236
MLInput mlinput = MLInput.builder()
241237
.inputDataset(new DataFrameInputDataset(inputDataFrame))
242238
//Just the placeholders for algorithm and parameters which must be initialized.
243239
//They will be overridden in ml client.
244240
.algorithm(FunctionName.SAMPLE_ALGO)
245241
.parameters(new SampleAlgoParams(0))
246242
.build();
247-
*/
243+
248244
MachineLearningNodeClient machineLearningClient =
249245
MLClient.getMLClient(nodeClient);
250246

251247
return machineLearningClient
252-
//.run(mlinput, arguments)
253-
.run(null, arguments)
248+
.run(mlinput, arguments)
254249
.actionGet(30, TimeUnit.SECONDS);
255250
}
256251

@@ -279,11 +274,10 @@ protected ExprTupleValue buildPPLResult(boolean isPredict,
279274

280275
protected ExprTupleValue buildTrainResult(MLTrainingOutput trainResult) {
281276
ImmutableMap.Builder<String, ExprValue> resultBuilder = new ImmutableMap.Builder<>();
282-
/*
283277
resultBuilder.put(MODELID, new ExprStringValue(trainResult.getModelId()));
284278
resultBuilder.put(TASKID, new ExprStringValue(trainResult.getTaskId()));
285279
resultBuilder.put(STATUS, new ExprStringValue(trainResult.getStatus()));
286-
*/
280+
287281
return ExprTupleValue.fromExprValueMap(resultBuilder.build());
288282
}
289283

opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void open() {
5050
Map<String, Object> args = processArgs(arguments);
5151

5252
MLOutput mlOutput = getMLOutput(inputDataFrame, args, nodeClient);
53-
final Iterator<Row> inputRowIter = Collections.emptyIterator();//inputDataFrame.iterator();
53+
final Iterator<Row> inputRowIter = inputDataFrame.iterator();
5454
// Only need to check train here, as action should be already checked in ml client.
5555
final boolean isPrediction = ((String) args.get("action")).equals("train") ? false : true;
5656
//For train, only one row to return.
@@ -59,9 +59,9 @@ public void open() {
5959
add("train");
6060
}
6161
}.iterator();
62-
final Iterator<Row> resultRowIter = Collections.emptyIterator();/*isPrediction
62+
final Iterator<Row> resultRowIter = isPrediction
6363
? ((MLPredictionOutput) mlOutput).getPredictionResult().iterator()
64-
: null;*/
64+
: null;
6565
iterator = new Iterator<ExprValue>() {
6666
@Override
6767
public boolean hasNext() {

opensearch/src/test/java/org/opensearch/sql/opensearch/client/OpenSearchNodeClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
import org.opensearch.common.collect.ImmutableOpenMap;
5858
import org.opensearch.common.settings.Settings;
5959
import org.opensearch.common.util.concurrent.ThreadContext;
60-
import org.opensearch.core.xcontent.DeprecationHandler;
61-
import org.opensearch.core.xcontent.NamedXContentRegistry;
62-
import org.opensearch.core.xcontent.XContentParser;
60+
import org.opensearch.common.xcontent.DeprecationHandler;
61+
import org.opensearch.common.xcontent.NamedXContentRegistry;
62+
import org.opensearch.common.xcontent.XContentParser;
6363
import org.opensearch.common.xcontent.XContentType;
6464
import org.opensearch.search.SearchHit;
6565
import org.opensearch.search.SearchHits;

opensearch/src/test/java/org/opensearch/sql/opensearch/client/OpenSearchRestClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
import org.opensearch.cluster.metadata.MappingMetadata;
5050
import org.opensearch.common.collect.ImmutableOpenMap;
5151
import org.opensearch.common.settings.Settings;
52-
import org.opensearch.core.xcontent.DeprecationHandler;
53-
import org.opensearch.core.xcontent.NamedXContentRegistry;
54-
import org.opensearch.core.xcontent.XContentParser;
52+
import org.opensearch.common.xcontent.DeprecationHandler;
53+
import org.opensearch.common.xcontent.NamedXContentRegistry;
54+
import org.opensearch.common.xcontent.XContentParser;
5555
import org.opensearch.common.xcontent.XContentType;
5656
import org.opensearch.search.SearchHit;
5757
import org.opensearch.search.SearchHits;

opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.opensearch.sql.planner.physical.PhysicalPlan;
4949
import org.opensearch.sql.planner.physical.PhysicalPlanNodeVisitor;
5050

51-
/*
5251
@ExtendWith(MockitoExtension.class)
5352
@MockitoSettings(strictness = Strictness.LENIENT)
5453
@RunWith(MockitoJUnitRunner.Silent.class)
@@ -135,4 +134,3 @@ public void testConvertArgumentToMLParameter_UnsupportedType() {
135134
}
136135

137136
}
138-
*/

opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.opensearch.sql.planner.physical.PhysicalPlan;
5454
import org.opensearch.sql.planner.physical.PhysicalPlanNodeVisitor;
5555

56-
/*
5756
@ExtendWith(MockitoExtension.class)
5857
@MockitoSettings(strictness = Strictness.LENIENT)
5958
@RunWith(MockitoJUnitRunner.Silent.class)
@@ -170,4 +169,3 @@ public void testAccept() {
170169
}
171170

172171
}
173-
*/

opensearch/src/test/java/org/opensearch/sql/opensearch/response/AggregationResponseUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import java.io.IOException;
1111
import java.util.List;
1212
import java.util.stream.Collectors;
13-
import org.opensearch.core.ParseField;
14-
import org.opensearch.core.xcontent.ContextParser;
13+
import org.opensearch.common.ParseField;
14+
import org.opensearch.common.xcontent.ContextParser;
1515
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
16-
import org.opensearch.core.xcontent.NamedXContentRegistry;
17-
import org.opensearch.core.xcontent.XContent;
16+
import org.opensearch.common.xcontent.NamedXContentRegistry;
17+
import org.opensearch.common.xcontent.XContent;
1818
import org.opensearch.common.xcontent.XContentFactory;
19-
import org.opensearch.core.xcontent.XContentParser;
19+
import org.opensearch.common.xcontent.XContentParser;
2020
import org.opensearch.common.xcontent.XContentType;
2121
import org.opensearch.search.aggregations.Aggregation;
2222
import org.opensearch.search.aggregations.Aggregations;

opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import static org.junit.jupiter.api.Assertions.assertEquals;
1010
import static org.mockito.Mockito.when;
11-
import static org.opensearch.core.xcontent.ToXContent.EMPTY_PARAMS;
11+
import static org.opensearch.common.xcontent.ToXContent.EMPTY_PARAMS;
1212
import static org.opensearch.sql.data.type.ExprCoreType.INTEGER;
1313
import static org.opensearch.sql.data.type.ExprCoreType.STRING;
1414
import static org.opensearch.sql.expression.DSL.literal;
@@ -28,7 +28,7 @@
2828
import org.mockito.Mock;
2929
import org.mockito.junit.jupiter.MockitoExtension;
3030
import org.opensearch.common.bytes.BytesReference;
31-
import org.opensearch.core.xcontent.XContentBuilder;
31+
import org.opensearch.common.xcontent.XContentBuilder;
3232
import org.opensearch.common.xcontent.XContentFactory;
3333
import org.opensearch.common.xcontent.XContentType;
3434
import org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder;

0 commit comments

Comments
 (0)