MCPcopy Create free account
hub / github.com/apache/arrow / Read

Method Read

cpp/src/arrow/csv/reader.cc:979–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977 }
978
979 Result<std::shared_ptr<Table>> Read() override {
980 task_group_ = TaskGroup::MakeSerial(io_context_.stop_token());
981
982 // First block
983 ARROW_ASSIGN_OR_RAISE(auto first_buffer, buffer_iterator_.Next());
984 if (first_buffer == nullptr) {
985 return Status::Invalid("Empty CSV file");
986 }
987 RETURN_NOT_OK(ProcessHeader(first_buffer, &first_buffer));
988 RETURN_NOT_OK(MakeColumnBuilders());
989
990 auto block_iterator = SerialBlockReader::MakeIterator(
991 std::move(buffer_iterator_), MakeChunker(parse_options_), std::move(first_buffer),
992 read_options_.skip_rows_after_names);
993 while (true) {
994 RETURN_NOT_OK(io_context_.stop_token().Poll());
995
996 ARROW_ASSIGN_OR_RAISE(auto maybe_block, block_iterator.Next());
997 if (IsIterationEnd(maybe_block)) {
998 // EOF
999 break;
1000 }
1001 RETURN_NOT_OK(ParseAndInsert(maybe_block));
1002 }
1003 // Finish conversion, create schema and table
1004 RETURN_NOT_OK(task_group_->Finish());
1005 return MakeTable();
1006 }
1007
1008 protected:
1009 Iterator<std::shared_ptr<Buffer>> buffer_iterator_;

Callers

nothing calls this directly

Calls 6

IsIterationEndFunction · 0.85
MakeTableFunction · 0.85
PollMethod · 0.80
MakeChunkerFunction · 0.70
InvalidFunction · 0.50
FinishMethod · 0.45

Tested by

no test coverage detected