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/21 02:25:31 UTC

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

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


##########
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:
   removed



##########
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:
   fixed



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