You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "CloudWise-Lukemiao (via GitHub)" <gi...@apache.org> on 2023/08/11 07:08:36 UTC
[GitHub] [iotdb] CloudWise-Lukemiao opened a new pull request, #10838: [To rel/1.2] Feature add insertRecords method to rest service
CloudWise-Lukemiao opened a new pull request, #10838:
URL: https://github.com/apache/iotdb/pull/10838
[To rel/1.2] Feature add insertRecords method to rest service
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] HTHou commented on a diff in pull request #10838: [To rel/1.2] Feature add insertRecords method to rest service
Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #10838:
URL: https://github.com/apache/iotdb/pull/10838#discussion_r1295342897
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java:
##########
@@ -164,4 +172,55 @@ public static InsertTabletStatement constructInsertTabletStatement(
insertStatement.setAligned(insertTabletRequest.getIsAligned());
return insertStatement;
}
+
+ public static InsertRowsStatement createInsertRowsStatement(
+ InsertRecordsRequest insertRecordsRequest)
+ throws IllegalPathException, QueryProcessException, IoTDBConnectionException {
+
+ // construct insert statement
+ InsertRowsStatement insertStatement = new InsertRowsStatement();
+ List<InsertRowStatement> insertRowStatementList = new ArrayList<>();
+ List<List<TSDataType>> dataTypesList = new ArrayList<>();
+
+ for (int i = 0; i < insertRecordsRequest.getDataTypesList().size(); i++) {
+ List<TSDataType> dataTypes = new ArrayList<>();
+ for (int c = 0; c < insertRecordsRequest.getDataTypesList().get(i).size(); c++) {
+ dataTypes.add(
+ TSDataType.valueOf(
+ insertRecordsRequest.getDataTypesList().get(i).get(c).toUpperCase(Locale.ROOT)));
+ }
+ dataTypesList.add(dataTypes);
+ }
+
+ InsertRowDataUtils.filterNullValueAndMeasurement(
+ insertRecordsRequest.getDeviceIds(),
+ insertRecordsRequest.getTimestamps(),
+ insertRecordsRequest.getMeasurementsList(),
+ insertRecordsRequest.getValuesList(),
+ dataTypesList);
+
+ List<ByteBuffer> valuesList =
+ InsertRowDataUtils.objectValuesListToByteBufferList(
+ insertRecordsRequest.getValuesList(), dataTypesList);
+
+ for (int i = 0; i < insertRecordsRequest.getDeviceIds().size(); i++) {
+ InsertRowStatement statement = new InsertRowStatement();
+ statement.setDevicePath(
+ DataNodeDevicePathCache.getInstance()
+ .getPartialPath(insertRecordsRequest.getDeviceIds().get(i)));
+ statement.setMeasurements(
+ insertRecordsRequest.getMeasurementsList().get(i).toArray(new String[0]));
+ statement.setTime(insertRecordsRequest.getTimestamps().get(i));
+ statement.fillValues(valuesList.get(i));
Review Comment:
I think convert the values to byte buffer and transfer back to objects is not a good idea. We can just set values directly to the insertStatement.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] HTHou merged pull request #10838: [To rel/1.2] Feature add insertRecords method to rest service
Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou merged PR #10838:
URL: https://github.com/apache/iotdb/pull/10838
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org