mrhhsg commented on code in PR #62835:
URL: https://github.com/apache/doris/pull/62835#discussion_r3142919350
##########
be/src/format/csv/csv_reader.cpp:
##########
@@ -377,26 +380,29 @@ Status CsvReader::_do_init_reader(ReaderInitContext*
base_ctx) {
return Status::OK();
}
+void CsvReader::set_batch_size(size_t batch_size) {
+ // 0 means "not set" / "use default" for the row-based readers; we must
+ // never let _batch_size be 0 because _do_get_next_block uses it as the
+ // upper bound of a `while (rows < _batch_size)` loop and a 0 would make
+ // the reader return empty blocks and incorrectly signal EOF.
+ _batch_size = std::max(_MIN_BATCH_SIZE, batch_size);
+}
+
// !FIXME: Here we should use MutableBlock
Status CsvReader::_do_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 = _batch_size;
+ const auto max_block_bytes = _state->preferred_block_size_bytes();
size_t rows = 0;
- size_t block_bytes = 0;
bool success = false;
bool is_remove_bom = false;
if (_push_down_agg_type == TPushAggOp::type::COUNT) {
- while (rows < batch_size && !_line_reader_eof &&
- (max_block_bytes <= 0 || (int64_t)block_bytes <
max_block_bytes)) {
Review Comment:
`TPushAggOp::type::COUNT` 没有必要控制 block bytes
##########
be/src/format/csv/csv_reader.cpp:
##########
@@ -433,8 +438,17 @@ Status CsvReader::_do_get_next_block(Block* block, size_t*
read_rows, bool* eof)
block->set_columns(std::move(mutate_columns));
} else {
auto columns = block->mutate_columns();
- while (rows < batch_size && !_line_reader_eof &&
- (max_block_bytes <= 0 || (int64_t)block_bytes <
max_block_bytes)) {
+ size_t next_checking_rows = 1;
+ auto get_block_bytes = [&]() {
+ if (_is_load) {
+ return block->bytes();
Review Comment:
query 模式下真正被增量填充的是本地 mutate 出来的 columns 集合,而不是整个 block;load 模式下 block
本身就是主要写入对象,用 block->bytes() 更直接。
--
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]