Skip to content

Commit 8d9036d

Browse files
feat(sink): merge small chunks for sink executor (#17825) (#17846)
Co-authored-by: Dylan <[email protected]>
1 parent 9f3af5a commit 8d9036d

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/stream/src/executor/sink.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,32 @@ impl<F: LogStoreFactory> SinkExecutor<F> {
339339
} else {
340340
chunks
341341
};
342-
let chunks = if re_construct_with_sink_pk {
343-
StreamChunkCompactor::new(down_stream_pk.clone(), chunks)
342+
if re_construct_with_sink_pk {
343+
let chunks = StreamChunkCompactor::new(down_stream_pk.clone(), chunks)
344344
.reconstructed_compacted_chunks(
345345
chunk_size,
346346
input_data_types.clone(),
347347
sink_type != SinkType::ForceAppendOnly,
348-
)
348+
);
349+
for c in chunks {
350+
yield Message::Chunk(c);
351+
}
349352
} else {
350-
chunks
353+
let mut chunk_builder =
354+
StreamChunkBuilder::new(chunk_size, input_data_types.clone());
355+
for chunk in chunks {
356+
for (op, row) in chunk.rows() {
357+
if let Some(c) = chunk_builder.append_row(op, row) {
358+
yield Message::Chunk(c);
359+
}
360+
}
361+
}
362+
363+
if let Some(c) = chunk_builder.take() {
364+
yield Message::Chunk(c);
365+
}
351366
};
352367

353-
for c in chunks {
354-
yield Message::Chunk(c);
355-
}
356368
if let Some(w) = mem::take(&mut watermark) {
357369
yield Message::Watermark(w)
358370
}

0 commit comments

Comments
 (0)