Skip to content

Commit 019fc20

Browse files
committed
test
1 parent 448ce42 commit 019fc20

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertNode;
2828
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.RelationalInsertTabletNode;
2929
import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
30-
import org.apache.iotdb.pipe.api.exception.PipeException;
3130

3231
import org.apache.tsfile.utils.Pair;
3332
import org.apache.tsfile.utils.PublicBAOS;
@@ -42,7 +41,6 @@
4241
import java.util.HashMap;
4342
import java.util.List;
4443
import java.util.Map;
45-
import java.util.Objects;
4644
import java.util.concurrent.atomic.AtomicLong;
4745
import java.util.function.BiConsumer;
4846

@@ -104,27 +102,29 @@ public PipeTransferTabletBatchReqV2 toTPipeTransferReq() throws IOException {
104102
final String databaseName = insertTablets.getKey();
105103
for (final Map.Entry<String, Pair<Integer, List<Tablet>>> tabletEntry :
106104
insertTablets.getValue().entrySet()) {
107-
Tablet batchTablet = null;
105+
final List<Tablet> batchTablets = new ArrayList<>();
108106
for (final Tablet tablet : tabletEntry.getValue().getRight()) {
109-
if (Objects.isNull(batchTablet)) {
110-
batchTablet = tablet;
111-
} else if (!batchTablet.append(tablet, tabletEntry.getValue().getLeft())) {
112-
throw new PipeException(
113-
"Failed to merge tablets due to inconsistent schema, database: "
114-
+ databaseName
115-
+ ", tableName: "
116-
+ tablet.getTableName());
107+
boolean success = false;
108+
for (final Tablet batchTablet : batchTablets) {
109+
if (batchTablet.append(tablet, tabletEntry.getValue().getLeft())) {
110+
success = true;
111+
break;
112+
}
113+
}
114+
if (!success) {
115+
batchTablets.add(tablet);
117116
}
118117
}
119-
assert batchTablet != null;
120-
try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
121-
final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
122-
batchTablet.serialize(outputStream);
123-
ReadWriteIOUtils.write(true, outputStream);
124-
tabletBuffers.add(
125-
ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()));
118+
for (final Tablet batchTablet : batchTablets) {
119+
try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
120+
final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
121+
batchTablet.serialize(outputStream);
122+
ReadWriteIOUtils.write(true, outputStream);
123+
tabletBuffers.add(
124+
ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()));
125+
}
126+
tabletDataBases.add(databaseName);
126127
}
127-
tabletDataBases.add(databaseName);
128128
}
129129
}
130130

0 commit comments

Comments
 (0)