You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/04/08 11:49:01 UTC
[GitHub] [iotdb] FrankHWD commented on a diff in pull request #4833: [IOTDB-2304]Library-UDF Data Repairing Functions
FrankHWD commented on code in PR #4833:
URL: https://github.com/apache/iotdb/pull/4833#discussion_r846032029
##########
docs/zh/UserGuide/UDF-Library/Data-Repairing.md:
##########
@@ -135,9 +135,9 @@ select timestamprepair(s1) from root.test.d2
**备注:** AR 模型采用 AR(1),时序列需满足自相关条件,否则将输出单个数据点 (0, 0.0).
### 使用示例
-
#### 使用 linear 方法进行填补
+>>>>>>> master:docs/zh/UserGuide/UDF-Library/Data-Repairing.md
Review Comment:
Done.
##########
library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueRepair.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.library.drepair;
+
+import org.apache.iotdb.db.query.udf.api.UDTF;
+import org.apache.iotdb.db.query.udf.api.access.RowWindow;
+import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
+import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.library.drepair.util.LsGreedy;
+import org.apache.iotdb.library.drepair.util.Screen;
+import org.apache.iotdb.library.drepair.util.ValueRepair;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+/** This function is used to repair the value of the time series. */
+public class UDTFValueRepair implements UDTF {
+ String method;
+ double minSpeed;
+ double maxSpeed;
+ double center;
+ double sigma;
+
+ @Override
+ public void validate(UDFParameterValidator validator) throws Exception {
+ validator
+ .validateInputSeriesNumber(1)
+ .validateInputSeriesDataType(
+ 0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64)
+ .validate(
+ x -> (double) x > 0,
+ "Parameter $sigma$ should be larger than 0.",
+ validator.getParameters().getDoubleOrDefault("sigma", 1.0))
+ .validate(
+ params -> (double) params[0] < (double) params[1],
+ "parameter $minSpeed$ should be smaller than $maxSpeed$.",
+ validator.getParameters().getDoubleOrDefault("minSpeed", -1),
+ validator.getParameters().getDoubleOrDefault("maxSpeed", 1));
+ }
+
+ @Override
+ public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
+ throws Exception {
+ configurations
+ .setAccessStrategy(new SlidingSizeWindowAccessStrategy(Integer.MAX_VALUE))
+ .setOutputDataType(parameters.getDataType(0));
+ method = parameters.getStringOrDefault("method", "screen");
+ minSpeed = parameters.getDoubleOrDefault("minSpeed", Double.NaN);
+ maxSpeed = parameters.getDoubleOrDefault("maxSpeed", Double.NaN);
+ center = parameters.getDoubleOrDefault("center", 0);
+ sigma = parameters.getDoubleOrDefault("sigma", Double.NaN);
+ }
+
+ @Override
+ public void transform(RowWindow rowWindow, PointCollector collector) throws Exception {
+ // 设置修复方法及参数
Review Comment:
Done.
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org