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 2020/11/26 15:42:39 UTC

[GitHub] [iotdb] 140378476 opened a new issue #2132: Incorrect result returned by `getFloat` in JDBC.

140378476 opened a new issue #2132:
URL: https://github.com/apache/iotdb/issues/2132


   **Describe the bug**
   I got clearly incorrect results when retrieving data using method `getFloat`. 
   Addtionally, I can get a String representation of the data, which is highly inprecise and requires extra parsing.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Create timeseries: ` CREATE TIMESERIES root.t.d WITH DATATYPE=FLOAT, ENCODING=RLE`
   2. Insert data: `INSERT INTO root.t(timestamp,d) VALUES(1,1.23456789)`
   3. Retrieve data using JDBC: (mostly copied from the user guide and converted to Kotlin)
   ```
       fun getConnection(): Connection? {
           // JDBC driver name and database URL
           val driver = "org.apache.iotdb.jdbc.IoTDBDriver"
           val url = "jdbc:iotdb://127.0.0.1:6667/"
   
           // Database credentials
           val username = "root"
           val password = "root"
           var connection: Connection? = null
           try {
               Class.forName(driver)
               connection = DriverManager.getConnection(url, username, password)
           } catch (e: ClassNotFoundException) {
               e.printStackTrace()
           } catch (e: SQLException) {
               e.printStackTrace()
           }
           return connection
       }
   
       fun select(){
           val connection = getConnection()
           if (connection == null) {
               println("get connection defeat")
               return
           }
           val statement: Statement = connection.createStatement()
           statement.execute("SELECT d from root.test")
           val rs = statement.resultSet
           rs.next()
           println("String:")
           println(rs.getString(2))
           println("Float:")
           println(rs.getFloat(2))
       }
   ```
   
   
   4. The output is:
   ```
   String:
   1.23
   Float:
   1.06728262E9
   ```
   I got the approximately correct result from `getString()` but incorrect result from `getFloat()`.
   
   **Expected behavior**
   I should get a precise float result from `getFloat()`. 
   
   **Desktop (please complete the following information):**
    - OS: [e.g. iOS]
    - Browser [e.g. chrome, safari]
    - Version [e.g. 22]
   
   
   
   **Additional context**
   The inplementation in `IoTDBRpcDataSet.java` shows that it just converts 
   the bytes to float in the method, while the bytes are actually in the format of String.
   
   A further dig into the source code shows that all data are in the format of String except the timestamp.
   Therefore, a simple fix is not possible because the issue is that the raw data transferred from the 
   database is in the format of String.
   This can cause precision loss and significant performance issue(extra parsing and formatting, more transfer cost).
   


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] 140378476 commented on issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
140378476 commented on issue #2132:
URL: https://github.com/apache/iotdb/issues/2132#issuecomment-734398120


   Using encoding type `GORILLA` did fix the precision loss issue, but the method `getFloat` still return
   incorrect values. 
   
   I will try to make a simple fix for the latter problem.


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] Alima777 commented on issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
Alima777 commented on issue #2132:
URL: https://github.com/apache/iotdb/issues/2132#issuecomment-734625138


   Hi, I checked the code and found it's a typo mistake: It's in 326 line of `AbstractIoTDBJDBCResultSet`. 
   
   Thanks for your detailed description!! If you don't mind, welcome to pull a PR to fix it :D


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] qiaojialin commented on issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on issue #2132:
URL: https://github.com/apache/iotdb/issues/2132#issuecomment-734569338


   Hi, thanks for your detailed description, and welcome to contribute 👍 


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] HTHou closed issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
HTHou closed issue #2132:
URL: https://github.com/apache/iotdb/issues/2132


   


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] HTHou commented on issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
HTHou commented on issue #2132:
URL: https://github.com/apache/iotdb/issues/2132#issuecomment-734383976


   Hi, same reason of your last question. Try to use encoding type `GORILLA `?


----------------------------------------------------------------
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.

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



[GitHub] [iotdb] HTHou commented on issue #2132: Incorrect result returned by `getFloat` in JDBC.

Posted by GitBox <gi...@apache.org>.
HTHou commented on issue #2132:
URL: https://github.com/apache/iotdb/issues/2132#issuecomment-739109041


   The bug is fixed. I'll close this issue. 


----------------------------------------------------------------
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.

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