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/06/09 16:15:25 UTC

[GitHub] [incubator-iotdb] puroc opened a new issue #1329: 30个设备,每个设备插入1万条记录,重复插入数据后,执行查询select count(*) from root align by device,报错Msg: 500: java.lang.Float cannot be cast to java.lang.Long

puroc opened a new issue #1329:
URL: https://github.com/apache/incubator-iotdb/issues/1329


   我的测试代码如下,连续执行两次,再执行select count(*) from root align by device,就会看到报错信息。
   
   ```java
   package iotdb;
   
   import java.sql.*;
   import java.text.SimpleDateFormat;
   import java.util.ArrayList;
   import java.util.Date;
   import java.util.List;
   
   public class PerformanceTest {
       public static final String URL = "jdbc:iotdb://192.168.235.101:6667/";
       public static int record = 10000;
       public static int deviceNum = 30;
       private static String startTime = "2020-01-01 00:00:00";
       private static final int BATCH_NUM = 50;
       public static final int INTERVAL = 15;
   
       public static void createGroup() {
           try (Connection connection = DriverManager.getConnection(URL, "root", "root");
                Statement statement = connection.createStatement()) {
               try {
                   statement.execute("SET STORAGE GROUP TO root.org1");
               } catch (Throwable e) {
                   e.printStackTrace();
               }
           } catch (Throwable e) {
               e.printStackTrace();
           }
       }
   
       public static void insert(String startTime) {
   
           long start = System.currentTimeMillis();
   
           List<Thread> list = new ArrayList<>();
           for (int i = 0; i < deviceNum; i++) {
               int finalI = i;
               Thread thread = new Thread(() -> {
                   try (Connection connection = DriverManager.getConnection(URL, "root", "root");
                        Statement statement = connection.createStatement()) {
                       TimeUtils timeUtils = new TimeUtils();
                       SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                       Date lastTime = sdf.parse(startTime);
                       for (int j = 0; j < record; j++) {
                           String sql = "insert into root.org1.flow.device" + finalI + "(timestamp, forward_flow, reverse_flow, instant_flow) values(" + sdf.format(lastTime) + "," + 100 + "," + 0 + "," + 50 + ")";
                           statement.addBatch(sql);
                           lastTime = timeUtils.addSecond(lastTime, INTERVAL);
                           if (record >= BATCH_NUM && j != 0 && j % BATCH_NUM == 0) {
                               statement.executeBatch();
                               statement.clearBatch();
                               System.out.println("batch insert");
                           }
                       }
                       statement.executeBatch();
                       statement.clearBatch();
                       System.out.println("final batch insert");
                   } catch (Throwable e) {
                       e.printStackTrace();
                   }
   
               });
               list.add(thread);
   
   
           }
           list.forEach(t -> {
               t.start();
           });
   
           list.forEach(t -> {
               try {
                   t.join();
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           });
   
           long end = System.currentTimeMillis();
           int total = deviceNum * record;
           long ms = end - start;
           System.out.println("insert finished.num:" + total + ",time:" + ms + ",rate:" + total / ms * 1000);
       }
   
       public static void main(String[] args) throws ClassNotFoundException, SQLException {
           for (int i = 0; i < args.length; i++) {
               String arg = args[i];
               if ("-deviceNum".equalsIgnoreCase(arg)) {
                   deviceNum = Integer.parseInt(args[i + 1]);
               } else if ("-record".equalsIgnoreCase(arg)) {
                   record = Integer.parseInt(args[i + 1]);
               } else if ("-startTime".equalsIgnoreCase(arg)) {
                   startTime = args[i + 1];
               } else {
                   continue;
               }
           }
   
           Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
           createGroup();
           insert(startTime);
   //        query();
       }
   
       private static void query() {
           try (Connection connection = DriverManager.getConnection(URL, "root", "root");
                Statement statement = connection.createStatement()) {
               ResultSet resultSet = statement.executeQuery("select count(*) from root.org1 align by device");
               outputResult(resultSet);
           } catch (Throwable e) {
               e.printStackTrace();
           }
       }
   
       private static void outputResult(ResultSet resultSet) throws SQLException {
           if (resultSet != null) {
               System.out.println("--------------------------");
               final ResultSetMetaData metaData = resultSet.getMetaData();
               final int columnCount = metaData.getColumnCount();
               for (int i = 0; i < columnCount; i++) {
                   System.out.print(metaData.getColumnLabel(i + 1) + " ");
               }
               System.out.println();
               while (resultSet.next()) {
                   for (int i = 1; ; i++) {
                       System.out.print(resultSet.getString(i));
                       if (i < columnCount) {
                           System.out.print(", ");
                       } else {
                           System.out.println();
                           break;
                       }
                   }
               }
               System.out.println("--------------------------\n");
           }
       }
   }
   ```


----------------------------------------------------------------
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] [incubator-iotdb] qiaojialin closed issue #1329: 30个设备,每个设备插入1万条记录,重复插入数据后,执行查询select count(*) from root align by device,报错Msg: 500: java.lang.Float cannot be cast to java.lang.Long

Posted by GitBox <gi...@apache.org>.
qiaojialin closed issue #1329:
URL: https://github.com/apache/incubator-iotdb/issues/1329


   


----------------------------------------------------------------
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] [incubator-iotdb] JackieTien97 commented on issue #1329: 30个设备,每个设备插入1万条记录,重复插入数据后,执行查询select count(*) from root align by device,报错Msg: 500: java.lang.Float cannot be cast to java.lang.Long

Posted by GitBox <gi...@apache.org>.
JackieTien97 commented on issue #1329:
URL: https://github.com/apache/incubator-iotdb/issues/1329#issuecomment-641058555


   Thanks for your feedback.
   
   The align by syntax will change the real series's type to the type of aggregation, i.e. the FLOAT type is transferred to Long type in this case, so while deserialize data, it will throw a such exception.
   
   It should be fixed in the rel/0.10.


----------------------------------------------------------------
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] [incubator-iotdb] qiaojialin commented on issue #1329: 30个设备,每个设备插入1万条记录,重复插入数据后,执行查询select count(*) from root align by device,报错Msg: 500: java.lang.Float cannot be cast to java.lang.Long

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


   https://github.com/apache/incubator-iotdb/pull/1335
   https://github.com/apache/incubator-iotdb/pull/1333
   
   This affects 0.10.0-SNAPSHOT version and is solved in this version.


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