This is an automated email from the ASF dual-hosted git repository.

lancelly pushed a commit to branch fixRealNumberCheck
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 80bb7d5814fe22cf11c39633ee24035c9ff8a8bf
Author: lancelly <[email protected]>
AuthorDate: Wed Dec 20 18:54:55 2023 +0800

    fixRealNumberJudge
---
 iotdb-client/service-rpc/pom.xml                   |  4 +++
 .../java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java | 12 ++++++++
 .../tsfile/read/common/parser/PathVisitor.java     | 10 ++++++-
 .../apache/iotdb/tsfile/read/common/PathTest.java  | 32 ++++++++++++++++++++++
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/iotdb-client/service-rpc/pom.xml b/iotdb-client/service-rpc/pom.xml
index 15836d4373a..6fbe96371ab 100644
--- a/iotdb-client/service-rpc/pom.xml
+++ b/iotdb-client/service-rpc/pom.xml
@@ -70,6 +70,10 @@
             <groupId>org.xerial.snappy</groupId>
             <artifactId>snappy-java</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
diff --git 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
index 6ff111e6bad..6505bcdedc1 100644
--- 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
+++ 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
@@ -31,6 +31,8 @@ import 
org.apache.iotdb.tsfile.read.common.block.column.TsBlockSerde;
 import org.apache.iotdb.tsfile.utils.Binary;
 
 import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.sql.Timestamp;
@@ -77,6 +79,12 @@ public class IoTDBRpcDataSet {
   public int tsBlockSize; // the size of current tsBlock
   public int tsBlockIndex; // the row index in current tsBlock
 
+  private long bytebufferCapacity = 0L;
+
+  private long bytebufferLimit = 0L;
+
+  private static Logger Logger = 
LoggerFactory.getLogger(IoTDBRpcDataSet.class);
+
   @SuppressWarnings({"squid:S3776", "squid:S107"}) // Suppress high Cognitive 
Complexity warning
   public IoTDBRpcDataSet(
       String sql,
@@ -297,6 +305,8 @@ public class IoTDBRpcDataSet {
       return true;
     } else {
       try {
+        Logger.error("Total capacity is : {}MB.", bytebufferCapacity / 1024 / 
1024);
+        Logger.error("Total limit is : {}MB.", bytebufferLimit / 1024 / 1024);
         close();
         return false;
       } catch (TException e) {
@@ -349,6 +359,8 @@ public class IoTDBRpcDataSet {
   public void constructOneTsBlock() {
     lastReadWasNull = false;
     ByteBuffer byteBuffer = queryResult.get(queryResultIndex);
+    bytebufferCapacity = bytebufferCapacity + (byteBuffer.capacity());
+    bytebufferLimit = bytebufferLimit + (byteBuffer.limit());
     queryResultIndex++;
     curTsBlock = serde.deserialize(byteBuffer);
     tsBlockIndex = -1;
diff --git 
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
 
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
index e5a1514a41b..d45dd93c1aa 100644
--- 
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
+++ 
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/parser/PathVisitor.java
@@ -92,6 +92,14 @@ public class PathVisitor extends 
PathParserBaseVisitor<String[]> {
         break;
       }
     }
-    return NumberUtils.isCreatable(str.substring(index));
+    if (index > 0 && (str.charAt(index) == 'e' || str.charAt(index) == 'E')) {
+      // first char encountered is e/E means the number is like: "000e38".(all 
leading zeros before
+      // e/E)
+      return NumberUtils.isCreatable(str.substring(index - 1));
+    } else {
+      // parse the str after removing the leading zeros
+      // Numbers like 0000 and 00.12 can also be handled by this branch
+      return NumberUtils.isCreatable(str.substring(index));
+    }
   }
 }
diff --git 
a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
 
b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
index a78f8132d47..99a4e1b7ed7 100644
--- 
a/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
+++ 
b/iotdb-core/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/PathTest.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.tsfile.read.common;
 
 import org.apache.iotdb.tsfile.exception.PathParseException;
+import org.apache.iotdb.tsfile.read.common.parser.PathVisitor;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -115,6 +116,18 @@ public class PathTest {
     p = new Path("root.sg.contains", true);
     Assert.assertEquals("root.sg", p.getDevice());
     Assert.assertEquals("contains", p.getMeasurement());
+
+    p = new Path("root.sg.`0000`", true);
+    Assert.assertEquals("root.sg", p.getDevice());
+    Assert.assertEquals("`0000`", p.getMeasurement());
+
+    p = new Path("root.sg.`0e38`", true);
+    Assert.assertEquals("root.sg", p.getDevice());
+    Assert.assertEquals("`0e38`", p.getMeasurement());
+
+    p = new Path("root.sg.`00.12`", true);
+    Assert.assertEquals("root.sg", p.getDevice());
+    Assert.assertEquals("`00.12`", p.getMeasurement());
   }
 
   @Test
@@ -170,5 +183,24 @@ public class PathTest {
       fail();
     } catch (PathParseException ignored) {
     }
+
+    try {
+      new Path("root.0e38", true);
+      fail();
+    } catch (PathParseException ignored) {
+    }
+
+    try {
+      new Path("root.0000", true);
+      fail();
+    } catch (PathParseException ignored) {
+    }
+  }
+
+  @Test
+  public void testRealNumber() {
+    Assert.assertTrue(PathVisitor.isRealNumber("0e38"));
+    Assert.assertTrue(PathVisitor.isRealNumber("0000"));
+    Assert.assertTrue(PathVisitor.isRealNumber("00.12"));
   }
 }

Reply via email to