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


##########
cpp/velox/operators/serializer/VeloxColumnarToRowConverter.cc:
##########
@@ -16,46 +16,61 @@
  */
 
 #include "VeloxColumnarToRowConverter.h"
+#include <velox/common/base/SuccinctPrinter.h>
+#include <cstdint>
 
 #include "memory/VeloxColumnarBatch.h"
+#include "utils/exception.h"
 #include "velox/row/UnsafeRowDeserializers.h"
 #include "velox/row/UnsafeRowFast.h"
 
 using namespace facebook;
 
 namespace gluten {
 
-void VeloxColumnarToRowConverter::refreshStates(facebook::velox::RowVectorPtr 
rowVector) {
-  numRows_ = rowVector->size();
+int64_t VeloxColumnarToRowConverter::refreshStates(
+    facebook::velox::RowVectorPtr rowVector,
+    int64_t rowId,
+    int64_t memoryThreshold) {
+  auto vectorLength = rowVector->size();
   numCols_ = rowVector->childrenSize();
 
   fast_ = std::make_unique<velox::row::UnsafeRowFast>(rowVector);
 
   size_t totalMemorySize = 0;
   if (auto fixedRowSize = 
velox::row::UnsafeRowFast::fixedRowSize(velox::asRowType(rowVector->type()))) {
-    totalMemorySize += fixedRowSize.value() * numRows_;
+    GLUTEN_CHECK(
+        memoryThreshold > fixedRowSize.value(),
+        "Only 1 row exceed Column2RowMemoryThreshold, which is " + 
velox::succinctBytes(memoryThreshold));
+    auto rowSize = fixedRowSize.value();
+    numRows_ = std::min<int64_t>(memoryThreshold / rowSize, vectorLength - 
rowId);

Review Comment:
   Why is it vectorLength - rowId? it might be negative?



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