JackieTien97 commented on code in PR #14364:
URL: https://github.com/apache/iotdb/pull/14364#discussion_r1877224960
##########
library-udf/src/main/java/org/apache/iotdb/library/util/Util.java:
##########
@@ -300,26 +300,72 @@ public static long mode(long[] values) {
* @param s input string
* @return timestamp
*/
- public static long parseTime(String s) {
+ public static long parseTime(String s, String timestampPrecision) {
long unit = 0;
s = s.toLowerCase();
s = s.replace(" ", "");
- if (s.endsWith("ms")) {
- unit = 1;
- s = s.substring(0, s.length() - 2);
- } else if (s.endsWith("s")) {
- unit = 1000;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("m")) {
- unit = 60 * 1000L;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("h")) {
- unit = 60 * 60 * 1000L;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("d")) {
- unit = 24 * 60 * 60 * 1000L;
- s = s.substring(0, s.length() - 1);
+ if (timestampPrecision.equals("ms")) {
Review Comment:
shoul throw Exception while meeting `ns` and `us`.
##########
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java:
##########
@@ -34,19 +34,22 @@
/** This function does upsample or downsample of input series. */
public class UDTFResample implements UDTF {
-
+ private static final String TIMESTAMP_PRECISION = "timestampPrecision";
+ public static final String MS_PRECISION = "ms";
Review Comment:
define these two fields in Util instead of defining them in each class
##########
library-udf/src/main/java/org/apache/iotdb/library/util/Util.java:
##########
@@ -300,26 +300,72 @@ public static long mode(long[] values) {
* @param s input string
* @return timestamp
*/
- public static long parseTime(String s) {
+ public static long parseTime(String s, String timestampPrecision) {
long unit = 0;
s = s.toLowerCase();
s = s.replace(" ", "");
- if (s.endsWith("ms")) {
- unit = 1;
- s = s.substring(0, s.length() - 2);
- } else if (s.endsWith("s")) {
- unit = 1000;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("m")) {
- unit = 60 * 1000L;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("h")) {
- unit = 60 * 60 * 1000L;
- s = s.substring(0, s.length() - 1);
- } else if (s.endsWith("d")) {
- unit = 24 * 60 * 60 * 1000L;
- s = s.substring(0, s.length() - 1);
+ if (timestampPrecision.equals("ms")) {
+ if (s.endsWith("ms")) {
+ unit = 1;
+ s = s.substring(0, s.length() - 2);
+ } else if (s.endsWith("s")) {
+ unit = 1000;
+ s = s.substring(0, s.length() - 1);
+ } else if (s.endsWith("m")) {
+ unit = 60 * 1000L;
+ s = s.substring(0, s.length() - 1);
+ } else if (s.endsWith("h")) {
+ unit = 60 * 60 * 1000L;
+ s = s.substring(0, s.length() - 1);
+ } else if (s.endsWith("d")) {
+ unit = 24 * 60 * 60 * 1000L;
+ s = s.substring(0, s.length() - 1);
+ }
+ } else if (timestampPrecision.equals("us")) {
Review Comment:
shoul throw Exception while meeting `ns`.
--
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]