shuwenwei commented on code in PR #16994:
URL: https://github.com/apache/iotdb/pull/16994#discussion_r2675221004
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/DeviceViewIntoOperator.java:
##########
@@ -192,4 +219,60 @@ public long ramBytesUsed() {
.mapToLong(InsertTabletStatementGenerator::ramBytesUsed)
.sum());
}
+
+ @Override
+ protected InsertMultiTabletsStatement
constructInsertMultiTabletsStatement(boolean needCheck) {
+ if (insertTabletStatementGenerators == null) {
+ return null;
+ }
+ boolean hasFullStatement =
existFullStatement(insertTabletStatementGenerators);
+ if (needCheck) {
+ // When needCheck is true, we only proceed if there already exists a
full statement.
+ if (!hasFullStatement) {
+ return null;
+ }
+ } else {
+ // When needCheck is false, we may delay flushing to accumulate more rows
+ // if the batch is not yet at the configured row limit and the child has
more data.
+ try {
+ if (batchedRowCount < CONFIG.getSelectIntoInsertTabletPlanRowLimit()
+ && child.hasNextWithTimer()) {
+ return null;
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntoProcessException(e.getMessage());
+ } catch (Exception e) {
+ throw new IntoProcessException(e.getMessage());
+ }
+ }
+ List<InsertTabletStatement> insertTabletStatementList = new ArrayList<>();
+ for (InsertTabletStatementGenerator generator :
insertTabletStatementGenerators) {
+ if (!generator.isEmpty()) {
+
insertTabletStatementList.add(generator.constructInsertTabletStatement());
+ }
+ }
+ if (insertTabletStatementList.isEmpty()) {
+ return null;
+ }
+
+ InsertMultiTabletsStatement insertMultiTabletsStatement = new
InsertMultiTabletsStatement();
+
insertMultiTabletsStatement.setInsertTabletStatementList(insertTabletStatementList);
+ batchedRowCount = 0;
+ return insertMultiTabletsStatement;
+ }
+
+ @Override
+ protected long findWritten(String device, String measurement) {
+ for (InsertTabletStatementGenerator generator :
insertTabletStatementGenerators) {
Review Comment:
```suggestion
for (int i = insertTabletStatementGenerators.size() - 1; i >= 0; i--) {
InsertTabletStatementGenerator generator =
insertTabletStatementGenerators.get(i);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]