[ 
https://issues.apache.org/jira/browse/IOTDB-999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17231133#comment-17231133
 ] 

Haonan Hou commented on IOTDB-999:
----------------------------------

Hi, I tried to write some text code like yours, but I didn't see any IoTDB 
problem. Here is the code.
{code:java}
//System.out.println("插入一个 Record,一个 Record 是一个设备一个时间戳下多个测点的数据。");
    List<String> measurements = new ArrayList<String>();
    List<String> values = new ArrayList<String>();
    ArrayList<String> lineList = new ArrayList<String>();
    lineList.add("ch1==ch2==ch3==ch4_'1'=='2'=='3'=='4'");
      //load the case file,storage the content into ArrayList by line,the case 
formate in line is like this ch1==ch2==ch3==ch4_'1'=='2'=='3'=='4',the left of 
'_' is sensor and the right of it is value,between sensor is '==',like the 
value. 
    for (int i = 0; i< lineList.size(); i++) {
      String[] tag_attribute = lineList.get(0).split("_");
      //split the lineList and storage into a string array.
      String[] senName = tag_attribute[0].split("==");
      for (int j = 0; j< senName.length; j++) { 
        measurements.add(senName[j]); 
      }
      String[] val = tag_attribute[1].split("==");
      for (int j=0; j < val.length; j++) { 
        values.add(val[j]); 
      }
    }
    insert1("root.sg.d1", measurements, values); //arg[3]是设备ID,不加root.的部分。

  public static void insert1(String deviceId,List<String> measurements, 
List<String> values) { 
    Date dt= new Date(); 
    long timeseries = dt.getTime(); 
    try { 
      System.out.println("begin session.insertRecord 写入"); 
      session.insertRecord(deviceId, timeseries, measurements, values);
      //there is no error tip in log and no record be inserted. 
      System.out.println("end session.insertRecord 写入"); 
    } catch (IoTDBConnectionException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
    } catch (StatementExecutionException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
{code}
And the result is as below:

!Screen Shot 2020-11-13 at 11.44.15 AM.png!

 

Your issue is probably because your data format. Try to catch all exception may 
help you to find the reason. :)

> insert record into the database use session.insertRecord ,there is no error 
> tip in log and no record be inserted.
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: IOTDB-999
>                 URL: https://issues.apache.org/jira/browse/IOTDB-999
>             Project: Apache IoTDB
>          Issue Type: Bug
>            Reporter: lming
>            Priority: Major
>         Attachments: Screen Shot 2020-11-13 at 11.44.15 AM.png
>
>
>  
> {code:java}
> if (exeType.equals("IRS1")) { 
>   //System.out.println("插入一个 Record,一个 Record 是一个设备一个时间戳下多个测点的数据。");
>   List<String> measurements = new ArrayList<String>();
>   List<String> values = new ArrayList<String>();
>   ArrayList<String> lineList = new ArrayList<String>();
>   try { 
>     lineList = lf.fetchLine(args[2]);
>     //load the case file,storage the content into ArrayList by line,the case 
> formate in line is like this ch1==ch2==ch3==ch4_'1'=='2'=='3'=='4',the left 
> of '_' is sensor and the right of it is value,between sensor is '==',like the 
> value. 
>   } catch (IOException e) { 
>     e.printStackTrace(); 
>   }
>   for (int i = 0; i< lineList.size(); i++) {
>     String[] tag_attribute = lineList.get.split("_");
>     //split the lineList and storage into a string array.
>     String[] senName = tag_attribute[0].split("==");
>     for (int j = 0; j< senName.length; j++) { 
>       measurements.add(senName[j]); 
>     }
>     String[] val = tag_attribute[1].split("==");
>     for (int j=0; j < val.length; j++) { 
>       values.add(val[j]); 
>     }
>   }
>   cit.insert1("root."+args[3], measurements, values); 
> //arg[3]是设备ID,不加root.的部分。
> }
> /**
> 插入一个 Record,一个 Record 是一个设备一个时间戳下多个测点的数据。服务器需要做类型推断,可能会有额外耗时 @param deviceId 
> @param time @param measurements @param values
>  */
> public void insert1(String deviceId,List<String> measurements, List<String> 
> values) { 
>   Date dt= new Date(); 
>   long timeseries = dt.getTime(); 
>   try { 
>     System.out.println("begin session.insertRecord 写入"); 
>     session.insertRecord(deviceId, timeseries, measurements, values);
>     //there is no error tip in log and no record be inserted. 
>     System.out.println("end session.insertRecord 写入"); 
>   } catch (IoTDBConnectionException e) { 
>     // TODO Auto-generated catch block 
>     e.printStackTrace(); 
>   } catch (StatementExecutionException e) { 
>     // TODO Auto-generated catch block 
>     e.printStackTrace(); 
>   } 
> }
> //问题:日志没有报错,没有内容写入。
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to