jinchengchenghh commented on code in PR #11140:
URL: 
https://github.com/apache/incubator-gluten/pull/11140#discussion_r2576441994


##########
cpp/velox/utils/VeloxBatchResizer.cc:
##########
@@ -78,22 +80,41 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() {
   if (cb->numRows() < minOutputBatchSize_) {
     auto vb = VeloxColumnarBatch::from(pool_, cb);
     auto rv = vb->getRowVector();
+    auto vector = std::static_pointer_cast<facebook::velox::BaseVector>(rv);

Review Comment:
   I don't see the vector usage



##########
cpp/velox/utils/VeloxBatchResizer.cc:
##########
@@ -78,22 +80,41 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() {
   if (cb->numRows() < minOutputBatchSize_) {
     auto vb = VeloxColumnarBatch::from(pool_, cb);
     auto rv = vb->getRowVector();
+    auto vector = std::static_pointer_cast<facebook::velox::BaseVector>(rv);
+    uint64_t numBytes = cb->numBytes();
+    if (numBytes > preferredBatchBytes_) {
+      // Input batch is too large. Just return it as is.
+      return cb;
+    }
     auto buffer = facebook::velox::RowVector::createEmpty(rv->type(), pool_);
     buffer->append(rv.get());
 
-    for (auto nextCb = in_->next(); nextCb != nullptr; nextCb = in_->next()) {
-      auto nextVb = VeloxColumnarBatch::from(pool_, nextCb);
-      auto nextRv = nextVb->getRowVector();
-      if (buffer->size() + nextRv->size() > maxOutputBatchSize_) {
+    // Call reset manully to potentially release memory
+    vector.reset();

Review Comment:
   L114 is enough, you reuse the variables in following for loop or release in 
the end



##########
cpp/velox/utils/VeloxBatchResizer.cc:
##########
@@ -78,22 +80,41 @@ std::shared_ptr<ColumnarBatch> VeloxBatchResizer::next() {
   if (cb->numRows() < minOutputBatchSize_) {
     auto vb = VeloxColumnarBatch::from(pool_, cb);
     auto rv = vb->getRowVector();
+    auto vector = std::static_pointer_cast<facebook::velox::BaseVector>(rv);
+    uint64_t numBytes = cb->numBytes();

Review Comment:
   Update here to only load the lazy vector, we don't need to flat dictionary 
vector   
https://github.com/apache/incubator-gluten/blob/7d491d5b373f77a3aa9a1bad14c34acb8987cfb5/cpp/velox/memory/VeloxColumnarBatch.cc#L82



-- 
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]

Reply via email to