This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 97046f9023c Encountering empty tablets during batch export of tsfile
does not affect subsequent export tasks (#14484)
97046f9023c is described below
commit 97046f9023c643be9bd08bdd65e85bc760c716eb
Author: Summer <[email protected]>
AuthorDate: Fri Dec 20 18:25:14 2024 +0800
Encountering empty tablets during batch export of tsfile does not affect
subsequent export tasks (#14484)
* [To dev/1.3]Support auto mkdirs in ExportData (#14378)
* Update export script prompt information (#14276)
* update export script prompt information
* update export script prompt information
* format
---------
Co-authored-by: 2b3c511 <[email protected]>
* auto mkdirs in ExportData
* update failed description
---------
Co-authored-by: 2b3c511 <[email protected]>
* Encountering empty tablets during batch export of tsfile does not affect
subsequent export tasks
* format
---------
Co-authored-by: 2b3c511 <[email protected]>
---
.../apache/iotdb/tools/it/ExportTsFileTestIT.java | 4 +--
.../org/apache/iotdb/tool/tsfile/ExportTsFile.java | 31 +++++++++++++---------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/tools/it/ExportTsFileTestIT.java
b/integration-test/src/test/java/org/apache/iotdb/tools/it/ExportTsFileTestIT.java
index 5994d4d554e..7701bb1f973 100644
---
a/integration-test/src/test/java/org/apache/iotdb/tools/it/ExportTsFileTestIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/tools/it/ExportTsFileTestIT.java
@@ -98,7 +98,7 @@ public class ExportTsFileTestIT extends AbstractScript {
"exit",
"%^errorlevel%");
builder.environment().put("CLASSPATH", libPath);
- testOutput(builder, output, 1);
+ testOutput(builder, output, 0);
prepareData();
@@ -148,7 +148,7 @@ public class ExportTsFileTestIT extends AbstractScript {
"-q",
"select * from root.**");
builder.environment().put("CLASSPATH", libPath);
- testOutput(builder, output, 1);
+ testOutput(builder, output, 0);
prepareData();
diff --git
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/tsfile/ExportTsFile.java
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/tsfile/ExportTsFile.java
index 322e7ad530c..18e8b00ea85 100644
---
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/tsfile/ExportTsFile.java
+++
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/tsfile/ExportTsFile.java
@@ -338,9 +338,11 @@ public class ExportTsFile extends AbstractTsFileTool {
final String path = targetDirectory + targetFile + index + ".tsfile";
try (SessionDataSet sessionDataSet = session.executeQueryStatement(sql,
timeout)) {
long start = System.currentTimeMillis();
- writeWithTablets(sessionDataSet, path);
- long end = System.currentTimeMillis();
- ioTPrinter.println("Export completely!cost: " + (end - start) + " ms.");
+ boolean isComplete = writeWithTablets(sessionDataSet, path);
+ if (isComplete) {
+ long end = System.currentTimeMillis();
+ ioTPrinter.println("Export completely!cost: " + (end - start) + "
ms.");
+ }
} catch (StatementExecutionException
| IoTDBConnectionException
| IOException
@@ -460,7 +462,7 @@ public class ExportTsFile extends AbstractTsFileTool {
"squid:S3776",
"squid:S6541"
}) // Suppress high Cognitive Complexity warning, Suppress many task in one
method warning
- public static void writeWithTablets(SessionDataSet sessionDataSet, String
filePath)
+ public static Boolean writeWithTablets(SessionDataSet sessionDataSet, String
filePath)
throws IOException,
IoTDBConnectionException,
StatementExecutionException,
@@ -471,7 +473,7 @@ public class ExportTsFile extends AbstractTsFileTool {
if (f.exists()) {
Files.delete(f.toPath());
}
-
+ boolean isEmpty = false;
try (TsFileWriter tsFileWriter = new TsFileWriter(f)) {
// device -> column indices in columnNames
Map<String, List<Integer>> deviceColumnIndices = new HashMap<>();
@@ -483,16 +485,19 @@ public class ExportTsFile extends AbstractTsFileTool {
List<Tablet> tabletList = constructTablets(deviceSchemaMap,
alignedDevices, tsFileWriter);
- if (tabletList.isEmpty()) {
- ioTPrinter.println("!!!Warning:Tablet is empty,no data can be
exported.");
- System.exit(CODE_ERROR);
+ if (!tabletList.isEmpty()) {
+ writeWithTablets(
+ sessionDataSet, tabletList, alignedDevices, tsFileWriter,
deviceColumnIndices);
+ tsFileWriter.flush();
+ } else {
+ isEmpty = true;
}
-
- writeWithTablets(
- sessionDataSet, tabletList, alignedDevices, tsFileWriter,
deviceColumnIndices);
-
- tsFileWriter.flush();
}
+ if (isEmpty) {
+ ioTPrinter.println("!!!Warning:Tablet is empty,no data can be
exported.");
+ return false;
+ }
+ return true;
}
private static void writeToTsFile(