This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch tsfile-tablet-converter
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/tsfile-tablet-converter by
this push:
new 572a6d8ed69 Update PipeStatementDataTypeConvertExecutionVisitor.java
572a6d8ed69 is described below
commit 572a6d8ed69949aea7951a9e4e479051cfa6ac45
Author: Steve Yurong Su <[email protected]>
AuthorDate: Tue Aug 20 19:00:54 2024 +0800
Update PipeStatementDataTypeConvertExecutionVisitor.java
---
...peStatementDataTypeConvertExecutionVisitor.java | 45 +++++++++++++---------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/visitor/PipeStatementDataTypeConvertExecutionVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/visitor/PipeStatementDataTypeConvertExecutionVisitor.java
index 7bc3e3d4cb5..fb11174ea5d 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/visitor/PipeStatementDataTypeConvertExecutionVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/visitor/PipeStatementDataTypeConvertExecutionVisitor.java
@@ -84,12 +84,14 @@ public class PipeStatementDataTypeConvertExecutionVisitor
@Override
public Optional<TSStatus> visitLoadFile(
final LoadTsFileStatement loadTsFileStatement, final TSStatus status) {
- // TODO: judge if the exception is caused by data type mismatch
- // TODO: convert the data type of the statement
- LOGGER.error(
- "Failed to execute LoadTsFileStatement and try to exec data type
conversion. LoadTsFileStatement: {}. Status: {}",
- loadTsFileStatement,
- status);
+ if (status.getCode() != TSStatusCode.LOAD_FILE_ERROR.getStatusCode()) {
+ return Optional.empty();
+ }
+
+ LOGGER.warn(
+ "Data type mismatch detected (TSStatus: {}) for LoadTsFileStatement:
{}. Start data type conversion.",
+ status,
+ loadTsFileStatement);
for (final File file : loadTsFileStatement.getTsFiles()) {
try (final TsFileInsertionScanDataContainer container =
@@ -100,23 +102,25 @@ public class PipeStatementDataTypeConvertExecutionVisitor
new PipeConvertedInsertTabletStatement(
PipeTransferTabletRawReq.toTPipeTransferRawReq(tablet, false)
.constructStatement());
- TSStatus result = statementExecutor.execute(statement);
-
- // Retry once if the write process is rejected
- if (result.getCode() ==
TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode()) {
- result = statementExecutor.execute(statement);
- }
-
- if (!(result.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
- || result.getCode() ==
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode())) {
+ try {
+ TSStatus result = statementExecutor.execute(statement);
+
+ // Retry once if the write process is rejected
+ if (result.getCode() ==
TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode()) {
+ result = statementExecutor.execute(statement);
+ }
+
+ if (!(result.getCode() ==
TSStatusCode.SUCCESS_STATUS.getStatusCode()
+ || result.getCode() ==
TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode())) {
+ return Optional.empty();
+ }
+ } catch (final Exception e) {
return Optional.empty();
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
LOGGER.warn(
- "Failed to scan TsFile for data type conversion.
LoadTsFileStatement: {}",
- loadTsFileStatement,
- e);
+ "Failed to convert data type for LoadTsFileStatement: {}.",
loadTsFileStatement, e);
return Optional.empty();
}
}
@@ -125,6 +129,9 @@ public class PipeStatementDataTypeConvertExecutionVisitor
loadTsFileStatement.getTsFiles().forEach(FileUtils::deleteQuietly);
}
+ LOGGER.warn(
+ "Data type conversion for LoadTsFileStatement: {} is successful.",
loadTsFileStatement);
+
return Optional.of(new
TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()));
}