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/06 13:27:17 UTC
[iotdb] 01/01: [IOTDB-1316] The importCsv tool should continue
inserting if a part of insertion failed
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch jira1316
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 36cf3cfd0c2e7e680de3815fd705c0f62c566124
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu May 6 21:26:33 2021 +0800
[IOTDB-1316] The importCsv tool should continue inserting if a part of insertion failed
---
cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 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 224d513..400479d 100644
--- a/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
+++ b/cli/src/main/java/org/apache/iotdb/tool/ImportCsv.java
@@ -167,7 +167,12 @@ 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) {
+ System.out.println("Meet error when insert csv because " + e.getMessage());
+ System.out.println("Continue inserting... ");
+ }
pb.stepTo(lineNumber + 1L);
devices = new ArrayList<>();
times = new ArrayList<>();
@@ -176,14 +181,19 @@ 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) {
+ System.out.println("Meet error when insert csv because " + e.getMessage());
+ System.out.println("Continue inserting... ");
+ }
System.out.println("Insert csv successfully!");
pb.stepTo(fileLine);
} catch (FileNotFoundException e) {
System.out.println("Cannot find " + file.getName() + " because: " + e.getMessage());
} catch (IOException e) {
System.out.println("CSV file read exception because: " + e.getMessage());
- } catch (IoTDBConnectionException | StatementExecutionException e) {
+ } catch (IoTDBConnectionException e) {
System.out.println("Meet error when insert csv because " + e.getMessage());
}
}