You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/05/08 09:19:56 UTC
[iotdb] branch rel/0.12 updated: [IOTDB-1316] The importCsv tool
should continue inserting if a part of insertion failed (#3131) (#3148)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.12 by this push:
new a68728d [IOTDB-1316] The importCsv tool should continue inserting if a part of insertion failed (#3131) (#3148)
a68728d is described below
commit a68728d945c93dfd3654ca79d3b286c1e30de760
Author: Haonan <hh...@outlook.com>
AuthorDate: Sat May 8 17:19:28 2021 +0800
[IOTDB-1316] The importCsv tool should continue inserting if a part of insertion failed (#3131) (#3148)
---
.../main/java/org/apache/iotdb/tool/ImportCsv.java | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
index fdf32b3..b0d3075 100644
--- a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
+++ b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
@@ -163,7 +163,16 @@ public class ImportCsv extends AbstractCsvTool {
measurementsList.add(devicesToMeasurements.get(device));
}
if (lineNumber % 10000 == 0) {
- session.insertRecords(devices, times, measurementsList, valuesList);
+ try {
+ session.insertRecords(devices, times, measurementsList, valuesList);
+ } catch (StatementExecutionException e) {
+ if (e.getMessage().contains("failed to insert measurements")) {
+ System.out.println("Meet error when insert csv because " + e.getMessage());
+ System.out.println("Continue inserting... ");
+ } else {
+ throw e;
+ }
+ }
pb.stepTo(lineNumber + 1L);
devices = new ArrayList<>();
times = new ArrayList<>();
@@ -172,7 +181,16 @@ public class ImportCsv extends AbstractCsvTool {
}
}
// TODO change it to insertTablet, now is slow
- session.insertRecords(devices, times, measurementsList, valuesList);
+ try {
+ session.insertRecords(devices, times, measurementsList, valuesList);
+ } catch (StatementExecutionException e) {
+ if (e.getMessage().contains("failed to insert measurements")) {
+ System.out.println("Meet error when insert csv because " + e.getMessage());
+ System.out.println("Continue inserting... ");
+ } else {
+ throw e;
+ }
+ }
System.out.println("Insert csv successfully!");
pb.stepTo(fileLine);
} catch (FileNotFoundException e) {