From 96a00e0273b5a1d245f74f570acfbdfd0b9bcaf9 Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Tue, 3 Jan 2023 18:29:48 +0800 Subject: [PATCH 1/8] improve the TimeSeriesRange fromString() --- .../iginx/metadata/entity/TimeSeriesRange.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java index f0e860607..d4903a6bf 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java @@ -98,9 +98,13 @@ default public void setEndTimeSeries(String endTimeSeries) { //Strange function: it should not work on the implementation of TimeSeriesPrefixRange public static TimeSeriesRange fromString(String str) { - String[] parts = str.split("-"); - assert parts.length == 2; - return new TimeSeriesInterval(parts[0].equals("null") ? null : parts[0], parts[1].equals("null") ? null : parts[1]); + if (str.contains("-")) { + String[] parts = str.split("-"); + assert parts.length == 2; + return new TimeSeriesInterval(parts[0].equals("null") ? null : parts[0], parts[1].equals("null") ? null : parts[1]); + } else { + return new TimeSeriesPrefixRange(str); + } } public boolean isContain(String tsName); From cd6a960bf734811fab563a49ad7afae556ea9b9a Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Thu, 5 Jan 2023 11:45:52 +0800 Subject: [PATCH 2/8] add some improvement --- .../iginx/metadata/entity/TimeSeriesRange.java | 15 ++++++++++++--- .../cn/edu/tsinghua/iginx/utils/StringUtils.java | 9 +++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java index d4903a6bf..c2cdc3e5d 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java @@ -22,6 +22,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static cn.edu.tsinghua.iginx.utils.StringUtils.isContainSpecialChar; + @JSONType(seeAlso = {TimeSeriesInterval.class, TimeSeriesPrefixRange.class}, typeKey = "type") public interface TimeSeriesRange extends Comparable { @@ -97,13 +99,20 @@ default public void setEndTimeSeries(String endTimeSeries) { public void setClosed(boolean closed); //Strange function: it should not work on the implementation of TimeSeriesPrefixRange - public static TimeSeriesRange fromString(String str) { - if (str.contains("-")) { + public static TimeSeriesRange fromString(String str) throws Exception { + if (str.contains("-") && !isContainSpecialChar(str)) { String[] parts = str.split("-"); assert parts.length == 2; return new TimeSeriesInterval(parts[0].equals("null") ? null : parts[0], parts[1].equals("null") ? null : parts[1]); } else { - return new TimeSeriesPrefixRange(str); + if (str.contains(".*") && str.indexOf(".*")==str.length()-2) + str = str.substring(0, str.length()-2); + if(!isContainSpecialChar(str)) + return new TimeSeriesPrefixRange(str); + else { + logger.error("Input invalid string format in TimeSeriesRange"); + throw new Exception("Input invalid string format in TimeSeriesRange"); + } } } diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index 9d00e256a..dac83bd80 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class StringUtils { @@ -106,4 +108,11 @@ public static String reformatColumnName(String name) { name = name.replaceAll("[)]", "[)]"); return name; } + + public static boolean isContainSpecialChar(String str) { + String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str); + return m.find(); + } } From 13c5b933704b67a9b81ca64679bc84212a6d0e8a Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Fri, 6 Jan 2023 09:23:17 +0800 Subject: [PATCH 3/8] fix --- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index dac83bd80..a90d480dd 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t"; + String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~!@#¥%……&*()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); From b391788452788069842c405619eafd3d19bab7ae Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Fri, 6 Jan 2023 19:35:27 +0800 Subject: [PATCH 4/8] fix --- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index a90d480dd..83578c42e 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~!@#¥%……&*()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; + String regEx = "[_`~!@#$%^&()+=|{}':;',<>?~!@#¥%……&()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); From c816e918a2cb54f72240d3a7b6ec914bb4200370 Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Fri, 6 Jan 2023 19:54:59 +0800 Subject: [PATCH 5/8] fix --- .../cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java | 2 +- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java index c2cdc3e5d..f09ce8ad5 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/entity/TimeSeriesRange.java @@ -105,7 +105,7 @@ public static TimeSeriesRange fromString(String str) throws Exception { assert parts.length == 2; return new TimeSeriesInterval(parts[0].equals("null") ? null : parts[0], parts[1].equals("null") ? null : parts[1]); } else { - if (str.contains(".*") && str.indexOf(".*")==str.length()-2) + if (str.contains(".*") && str.indexOf(".*") == str.length() - 2) str = str.substring(0, str.length()-2); if(!isContainSpecialChar(str)) return new TimeSeriesPrefixRange(str); diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index 83578c42e..9d16d5568 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[_`~!@#$%^&()+=|{}':;',<>?~!@#¥%……&()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; + String regEx = "[`~!@#$%^&()+=|{}':;',<>?~!@#¥%……&()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); From ebeeec2273d5879b83aaf1ee152fd4aeef704358 Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Sat, 14 Jan 2023 17:13:04 +0800 Subject: [PATCH 6/8] fix it --- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index 9d16d5568..2995c6904 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[`~!@#$%^&()+=|{}':;',<>?~!@#¥%……&()+|{}【】‘;:”“’。,、?]|\n|\r|\t"; + String regEx = "[~!@#$%&()+=|{}':;',<>?~]|\n|\n|\t|[\u2E80-\u9FFF]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); From aea49bb09c4df71b6a65b3b335a95fa312ccf269 Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Tue, 17 Jan 2023 16:36:35 +0800 Subject: [PATCH 7/8] fix --- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index 2995c6904..8dfd42db7 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[~!@#$%&()+=|{}':;',<>?~]|\n|\n|\t|[\u2E80-\u9FFF]"; + String regEx = "[~!@#$%&()+=|{}':;',<>?~]|\r|\n|\t|[\u2E80-\u9FFF]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); From a7cdb2757e4d0aac8a503f522d48f07db5894b40 Mon Sep 17 00:00:00 2001 From: RemHero <1104304963@qq.com> Date: Thu, 19 Jan 2023 19:02:25 +0800 Subject: [PATCH 8/8] Reduce the range of sql Chinese character sets --- antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 | 2 +- .../src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 b/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 index 5de41ee2f..a4f0e1949 100644 --- a/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 +++ b/antlr/src/main/antlr4/cn/edu/tsinghua/iginx/sql/Sql.g4 @@ -813,7 +813,7 @@ NAME_CHAR ; fragment CN_CHAR - : '\u2E80'..'\u9FFF' + : '\u2E85'..'\u9FFF' ; DOUBLE_QUOTE_STRING_LITERAL diff --git a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java index 8dfd42db7..cc81c6ca9 100644 --- a/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java +++ b/shared/src/main/java/cn/edu/tsinghua/iginx/utils/StringUtils.java @@ -110,7 +110,7 @@ public static String reformatColumnName(String name) { } public static boolean isContainSpecialChar(String str) { - String regEx = "[~!@#$%&()+=|{}':;',<>?~]|\r|\n|\t|[\u2E80-\u9FFF]"; + String regEx = "[~!@#$%&()+=|{}':;',<>?~]|\r|\n|\t|[\u2E80-\u2E84]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find();