SteveYurongSu commented on code in PR #12146:
URL: https://github.com/apache/iotdb/pull/12146#discussion_r1524387888


##########
library-udf/src/main/java/org/apache/iotdb/library/frequency/UDFEnvelopeAnalysis.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.frequency;
+
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import 
org.apache.iotdb.udf.api.exception.UDFOutputSeriesDataTypeNotValidException;
+import org.apache.iotdb.udf.api.type.Type;
+
+import org.apache.commons.math3.complex.Complex;
+import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
+import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
+import org.jtransforms.fft.DoubleFFT_1D;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class UDFEnvelopeAnalysis implements UDTF {
+  private double frequency;
+  private int amplification;
+  private String timestampPrecision;
+  private final DoubleArrayList signals = new DoubleArrayList();
+  private final LongArrayList timestamps = new LongArrayList();
+  private static final String TIMESTAMP_PRECISION = "timestampPrecision";
+  private static final String FREQUENCY = "frequency";
+  private static final String AMPLIFICATION = "amplification";
+  public static final String MS_PRECISION = "ms";
+  public static final String US_PRECISION = "us";
+  public static final String NS_PRECISION = "ns";
+
+  @Override
+  public void validate(UDFParameterValidator validator) throws Exception {
+    validator
+        .validateInputSeriesNumber(1)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, 
Type.INT64)
+        .validate(
+            x -> (double) x >= 0,
+            "The param 'frequency' must greater than 0.",
+            validator.getParameters().getDoubleOrDefault(FREQUENCY, 0))
+        .validate(
+            x -> (int) x >= 1,
+            "The param 'amplification' must greater than 1.",
+            validator.getParameters().getIntOrDefault(AMPLIFICATION, 1));

Review Comment:
   ```suggestion
           .validate(
               x -> (double) x > 0,
               "The param 'frequency' must be > 0.",
               validator.getParameters().getDoubleOrDefault(FREQUENCY, 0))
           .validate(
               x -> (int) x >= 1,
               "The param 'amplification' must be >= 1.",
               validator.getParameters().getIntOrDefault(AMPLIFICATION, 1));
   ```



-- 
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-unsubscr...@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to