github-actions[bot] commented on code in PR #61535:
URL: https://github.com/apache/doris/pull/61535#discussion_r3078811534


##########
be/src/format/json/new_json_reader.cpp:
##########
@@ -196,20 +196,21 @@ Status NewJsonReader::init_reader(
     return Status::OK();
 }
 
+void NewJsonReader::set_batch_size(size_t batch_size) {
+    _batch_size = batch_size;
+}
+
 Status NewJsonReader::get_next_block(Block* block, size_t* read_rows, bool* 
eof) {
     if (_reader_eof) {
         *eof = true;
         return Status::OK();
     }
 
-    const int batch_size = std::max(_state->batch_size(), 
(int)_MIN_BATCH_SIZE);
-    const int64_t max_block_bytes =
-            (_state->query_type() == TQueryType::LOAD && 
config::load_reader_max_block_bytes > 0)
-                    ? config::load_reader_max_block_bytes
-                    : 0;
+    const auto batch_size = _state->batch_size();
+    const auto max_block_bytes = _state->preferred_block_size_bytes();

Review Comment:
   Same issue as the CSV reader: `FileScanner` updates this reader through 
`set_batch_size(...)`, but `get_next_block()` still uses `_state->batch_size()` 
as its row cap. So the new predictor does not actually control JSON batch size, 
and the adaptive path for wide/narrow JSON files is effectively bypassed here.



##########
be/src/format/csv/csv_reader.cpp:
##########
@@ -307,26 +308,25 @@ Status CsvReader::init_reader(bool is_load) {
     return Status::OK();
 }
 
+void CsvReader::set_batch_size(size_t batch_size) {
+    _batch_size = batch_size;
+}
+
 // !FIXME: Here we should use MutableBlock
 Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
     if (_line_reader_eof) {
         *eof = true;
         return Status::OK();
     }
 
-    const int batch_size = std::max(_state->batch_size(), 
(int)_MIN_BATCH_SIZE);
-    const int64_t max_block_bytes =
-            (_state->query_type() == TQueryType::LOAD && 
config::load_reader_max_block_bytes > 0)
-                    ? config::load_reader_max_block_bytes
-                    : 0;
+    const size_t batch_size = _state->batch_size();
+    const auto max_block_bytes = _state->preferred_block_size_bytes();

Review Comment:
   `FileScanner` now calls `set_batch_size(_predict_reader_batch_rows())`, but 
this loop still caps on `_state->batch_size()` instead of the reader-local 
`_batch_size`. As a result the EWMA predictor never actually changes the row 
count for CSV scans; the reader only uses the sampled byte cutoff after rows 
have already been appended. That leaves adaptive batch sizing ineffective for 
CSV inputs.



##########
be/src/runtime/runtime_state.h:
##########
@@ -138,7 +138,38 @@ class RuntimeState {
 
     const DescriptorTbl& desc_tbl() const { return *_desc_tbl; }
     void set_desc_tbl(const DescriptorTbl* desc_tbl) { _desc_tbl = desc_tbl; }
-    MOCK_FUNCTION int batch_size() const { return _query_options.batch_size; }
+
+    // Row-count limit for output blocks (default 65535, range [1, 65535]).
+    // Consistent with SessionVariable.batchSize on FE side.
+    MOCK_FUNCTION int batch_size() const {
+        static constexpr int kDefault = 65535;
+        auto v = _query_options.batch_size;
+        return std::min(std::max(1, v), kDefault);
+    }
+
+    // Target byte budget per output block (default 8MB).
+    // FE validates the range [1MB, 512MB] in SessionVariable; BE trusts that
+    // but applies a default when the field is unset or zero.
+    MOCK_FUNCTION size_t preferred_block_size_bytes() const {
+        static constexpr int64_t kDefault = 8388608L; // 8MB
+        if (_query_options.__isset.preferred_block_size_bytes &&
+            _query_options.preferred_block_size_bytes > 0) {
+            return _query_options.preferred_block_size_bytes;
+        }
+        return kDefault;
+    }

Review Comment:
   `preferred_block_size_bytes = 0` is documented as the way to disable 
adaptive sizing, but this accessor maps both `unset` and explicit `0` back to 
the 8MB default. That means every caller still sees byte-budget mode as 
enabled, and FE also rejects `0` in `checkPreferredBlockSizeBytes()`. 
Concretely, the advertised `SET preferred_block_size_bytes = 0` opt-out cannot 
work end to end. Please preserve an explicit zero here (and allow FE to send 
it) if zero is meant to disable the feature.



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