[CodeFormat] Clang-format cpp sources (#4965)

Clang-format all c++ source files.
This commit is contained in:
sduzh
2020-11-28 18:36:49 +08:00
committed by GitHub
parent f944bf4d44
commit 6fedf5881b
1331 changed files with 62548 additions and 68514 deletions

View File

@ -20,73 +20,72 @@
#include <boost/algorithm/string.hpp>
namespace doris {
CsvScanner::CsvScanner(const std::vector<std::string>& csv_file_paths) :
_is_open(false),
_file_paths(csv_file_paths),
_current_file(nullptr),
_current_file_idx(0){
// do nothing
CsvScanner::CsvScanner(const std::vector<std::string>& csv_file_paths)
: _is_open(false),
_file_paths(csv_file_paths),
_current_file(nullptr),
_current_file_idx(0) {
// do nothing
}
CsvScanner::~CsvScanner() {
// close file
if (_current_file != nullptr) {
if (_current_file->is_open()) {
_current_file->close();
}
delete _current_file;
_current_file = nullptr;
}
}
CsvScanner::~CsvScanner() {
// close file
if (_current_file != nullptr) {
if (_current_file->is_open()) {
_current_file->close();
}
delete _current_file;
_current_file = nullptr;
}
}
Status CsvScanner::open() {
VLOG(1) << "CsvScanner::Connect";
Status CsvScanner::open() {
VLOG(1) << "CsvScanner::Connect";
if (_is_open) {
LOG(INFO) << "this scanner already opened";
return Status::OK();
}
if (_file_paths.empty()) {
return Status::InternalError("no file specified.");
}
_is_open = true;
if (_is_open) {
LOG(INFO) << "this scanner already opened";
return Status::OK();
}
// TODO(lingbin): read more than one line at a time to reduce IO comsumption
Status CsvScanner::get_next_row(std::string* line_str, bool* eos) {
if (_current_file == nullptr && _current_file_idx == _file_paths.size()) {
if (_file_paths.empty()) {
return Status::InternalError("no file specified.");
}
_is_open = true;
return Status::OK();
}
// TODO(lingbin): read more than one line at a time to reduce IO comsumption
Status CsvScanner::get_next_row(std::string* line_str, bool* eos) {
if (_current_file == nullptr && _current_file_idx == _file_paths.size()) {
*eos = true;
return Status::OK();
}
if (_current_file == nullptr && _current_file_idx < _file_paths.size()) {
std::string& file_path = _file_paths[_current_file_idx];
LOG(INFO) << "open csv file: [" << _current_file_idx << "] " << file_path;
_current_file = new std::ifstream(file_path, std::ifstream::in);
if (!_current_file->is_open()) {
return Status::InternalError("Fail to read csv file: " + file_path);
}
++_current_file_idx;
}
getline(*_current_file, *line_str);
if (_current_file->eof()) {
_current_file->close();
delete _current_file;
_current_file = nullptr;
if (_current_file_idx == _file_paths.size()) {
*eos = true;
return Status::OK();
}
if (_current_file == nullptr && _current_file_idx < _file_paths.size()) {
std::string& file_path = _file_paths[_current_file_idx];
LOG(INFO) << "open csv file: [" << _current_file_idx << "] " << file_path;
_current_file = new std::ifstream(file_path, std::ifstream::in);
if (!_current_file->is_open()) {
return Status::InternalError("Fail to read csv file: " + file_path);
}
++_current_file_idx;
}
getline(*_current_file, *line_str);
if (_current_file->eof()) {
_current_file->close();
delete _current_file;
_current_file = nullptr;
if (_current_file_idx == _file_paths.size()) {
*eos = true;
return Status::OK();
}
}
*eos = false;
return Status::OK();
}
} // end namespace doris
*eos = false;
return Status::OK();
}
} // end namespace doris