jinchengchenghh commented on code in PR #6869:
URL: https://github.com/apache/incubator-gluten/pull/6869#discussion_r1744862909
##########
cpp/velox/shuffle/VeloxShuffleReader.cc:
##########
@@ -403,16 +403,44 @@ std::shared_ptr<ColumnarBatch>
VeloxSortShuffleReaderDeserializer::next() {
GLUTEN_ASSIGN_OR_THROW(
auto arrowBuffers, BlockPayload::deserialize(in_.get(), codec_,
arrowPool_, numRows, decompressTime_));
- if (numRows == 0) {
+ if (arrowBuffers.empty()) {
reachEos_ = true;
if (cachedRows_ > 0) {
return deserializeToBatch();
}
return nullptr;
}
- auto buffer = std::move(arrowBuffers[0]);
- cachedInputs_.emplace_back(numRows,
wrapInBufferViewAsOwner(buffer->data(), buffer->size(), buffer));
- cachedRows_ += numRows;
+
+ if (numRows > 0) {
+ auto buffer = std::move(arrowBuffers[0]);
+ cachedInputs_.emplace_back(numRows,
wrapInBufferViewAsOwner(buffer->data(), buffer->size(), buffer));
+ cachedRows_ += numRows;
+ } else {
+ // numRows = 0 indicates a segment of a large row.
+ std::vector<std::shared_ptr<arrow::Buffer>> buffers;
+ auto rowSize =
*reinterpret_cast<RowSizeType*>(const_cast<uint8_t*>(arrowBuffers[0]->data()));
+ RowSizeType bufferSize = arrowBuffers[0]->size();
+ buffers.emplace_back(std::move(arrowBuffers[0]));
+ // Read remaining segments.
+ while (bufferSize < rowSize) {
+ GLUTEN_ASSIGN_OR_THROW(
+ arrowBuffers, BlockPayload::deserialize(in_.get(), codec_,
arrowPool_, numRows, decompressTime_));
+ bufferSize += arrowBuffers[0]->size();
+ buffers.emplace_back(std::move(arrowBuffers[0]));
+ }
+ VELOX_CHECK_EQ(bufferSize, rowSize);
+ // Merge all segments.
+ GLUTEN_ASSIGN_OR_THROW(std::shared_ptr<arrow::Buffer> rowBuffer,
arrow::AllocateBuffer(rowSize, arrowPool_));
+ RowSizeType bytes = 0;
+ auto* dst = rowBuffer->mutable_data();
+ for (const auto& buffer : buffers) {
+ VELOX_CHECK_NOT_NULL(buffer);
Review Comment:
VELOX_DCHECK, code logic should use DCHECK
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]