You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/20 16:01:32 UTC

[GitHub] [doris] BePPPower commented on a diff in pull request #13515: [fix](csv-reader) fix bug that csv reader can not read text format hms table

BePPPower commented on code in PR #13515:
URL: https://github.com/apache/doris/pull/13515#discussion_r1000829421


##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -150,16 +175,15 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
             continue;
         }
 
-        // TODO(ftw): check read_rows?
-        ++(*read_rows);
-        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), columns));
+        RETURN_IF_ERROR(_fill_dest_columns(Slice(ptr, size), block));
+        ++rows;
 
         if (_line_reader_eof == true) {
             *eof = true;
             break;
         }

Review Comment:
   I think this judgment is redundant and it is wasting time if we judge it every time in the `while` loop.
   ```suggestion
   ```



##########
be/src/vec/exec/format/csv/csv_reader.cpp:
##########
@@ -134,10 +150,19 @@ Status CsvReader::get_next_block(Block* block, size_t* read_rows, bool* eof) {
         return Status::OK();
     }
 
-    const int batch_size = _state->batch_size();
-    auto columns = block->mutate_columns();
+    if (!_init_column_pos) {
+        // Save mapping from file slot desc to column in block, so that we don't need to
+        // find column in block by name every time.
+        for (int i = 0; i < _file_slot_descs.size(); ++i) {
+            size_t position = block->get_position_by_name(_file_slot_descs[i]->col_name());
+            _col_posistions.push_back(position);
+        }
+        _init_column_pos = true;
+    }
 
-    while (columns[0]->size() < batch_size && !_line_reader_eof) {
+    const int batch_size = _state->batch_size();
+    int rows = 0;
+    while (rows < batch_size && !_line_reader_eof) {

Review Comment:
   `_fill_dest_columns` may filter invalid line and `block` does not actually add a new line. But `++rows` may make the `while(row < bactch_size)` exit in advance.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org