JackieTien97 commented on code in PR #15021:
URL: https://github.com/apache/iotdb/pull/15021#discussion_r2004938232
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ModelManager.java:
##########
@@ -125,6 +141,39 @@ public TGetModelInfoResp getModelInfo(TGetModelInfoReq
req) {
}
}
+ // Currently this method is only used by built-in timer_xl
+ public TSStatus updateModelInfo(TUpdateModelInfoReq req) {
+ if (!modelInfo.contain(req.getModelId())) {
+ return new TSStatus(TSStatusCode.MODEL_EXIST_ERROR.getStatusCode())
Review Comment:
```suggestion
return new TSStatus(TSStatusCode.MODEL_NOT_EXIST_ERROR.getStatusCode())
```
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java:
##########
@@ -2577,6 +2587,97 @@ public TSStatus createModel(TCreateModelReq req) {
: status;
}
+ private List<ITableSchema> fetchSchemaForTreeModel(TCreateTrainingReq req) {
+ List<ITableSchema> tableSchemaList = new ArrayList<>();
+ if (req.useAllData) {
+ tableSchemaList.add(new ITableSchema("root.**", ""));
+ return tableSchemaList;
+ }
+ for (int i = 0; i < req.getTargetDbsSize(); i++) {
+ ITableSchema tableSchema = new ITableSchema(req.getTargetDbs().get(i),
"");
+ tableSchema.setTimeRange(req.getTimeRanges().get(i));
+ tableSchemaList.add(tableSchema);
Review Comment:
use another different datastructure
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/model/CreateTrainingStatement.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.statement.metadata.model;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
+import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor;
+
+import java.util.List;
+import java.util.Map;
+
+public class CreateTrainingStatement extends Statement implements
IConfigStatement {
+
+ String modelId;
+ String modelType;
+
+ Map<String, String> parameters;
+ String existingModelId = null;
+
+ List<PartialPath> targetPathPatterns;
+ List<List<Long>> targetTimeRanges;
Review Comment:
add private
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java:
##########
@@ -758,4 +765,23 @@ public IConfigTask visitShowCurrentSqlDialect(
ShowCurrentSqlDialectStatement node, MPPQueryContext context) {
return new
ShowCurrentSqlDialectTask(context.getSession().getSqlDialect().name());
}
+
+ @Override
+ public IConfigTask visitCreateTraining(
+ CreateTrainingStatement createTrainingStatement, MPPQueryContext
context) {
+ List<PartialPath> partialPathList =
createTrainingStatement.getTargetPathPatterns();
+ List<String> targetPathPatterns = new ArrayList<>();
+ for (PartialPath partialPath : partialPathList) {
+ targetPathPatterns.add(partialPath.getFullPath());
+ }
+ CreateTraining createTraining =
+ new CreateTraining(
+ createTrainingStatement.getModelId(),
createTrainingStatement.getModelType(), false);
+ createTraining.setTargetDbs(targetPathPatterns);
+ createTraining.setParameters(createTrainingStatement.getParameters());
+
createTraining.setExistingModelId(createTrainingStatement.getExistingModelId());
+ createTraining.setUseAllData(false);
+
createTraining.setTargetTimeRanges(createTrainingStatement.getTargetTimeRanges());
Review Comment:
Add a new Plan for tree model, avoid reusing this which is totally unreadable
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateTraining.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
+
+import java.util.List;
+import java.util.Map;
+
+public class CreateTraining extends Statement {
+
+ private final String modelId;
+ private String curDatabase;
+ private final String modelType;
+ private final boolean isTableModel;
Review Comment:
what's this used for?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/model/CreateTrainingStatement.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.statement.metadata.model;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
+import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor;
+
+import java.util.List;
+import java.util.Map;
+
+public class CreateTrainingStatement extends Statement implements
IConfigStatement {
+
+ String modelId;
+ String modelType;
+
+ Map<String, String> parameters;
+ String existingModelId = null;
+
+ List<PartialPath> targetPathPatterns;
+ List<List<Long>> targetTimeRanges;
+
+ public CreateTrainingStatement(String modelId, String modelType) {
+ this.modelId = modelId;
+ this.modelType = modelType;
+ }
+
+ public void setTargetPathPatterns(List<PartialPath> targetPathPatterns) {
+ this.targetPathPatterns = targetPathPatterns;
+ }
+
+ public Map<String, String> getParameters() {
+ return parameters;
+ }
+
+ public String getExistingModelId() {
+ return existingModelId;
+ }
+
+ public List<PartialPath> getTargetPathPatterns() {
+ return targetPathPatterns;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public String getModelType() {
+ return modelType;
+ }
+
+ public void setExistingModelId(String existingModelId) {
+ this.existingModelId = existingModelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public void setTargetTimeRanges(List<List<Long>> targetTimeRanges) {
+ this.targetTimeRanges = targetTimeRanges;
+ }
+
+ public List<List<Long>> getTargetTimeRanges() {
+ return targetTimeRanges;
+ }
+
+ public void setParameters(Map<String, String> parameters) {
+ this.parameters = parameters;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return null;
+ }
Review Comment:
implement these
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]