提交 471ecfca 编写于 作者: J jiangzhiwen

adapt euler eof

上级 387dac58
......@@ -411,7 +411,10 @@ Status CsvOp::LoadFile(const std::string &file, const int64_t start_offset, cons
csv_parser.Reset();
try {
while (ifs.good()) {
char chr = ifs.get();
// when ifstream reachs the end of file, the function get() return std::char_traits<char>::eof()
// which is a 32-bit -1, it's not equal to the 8-bit -1 on Euler OS. So instead of char, we use
// int to receive its return value.
int chr = ifs.get();
if (csv_parser.processMessage(chr) != 0) {
RETURN_STATUS_UNEXPECTED("Failed to parse file " + file + ":" + std::to_string(csv_parser.total_rows_ + 1) +
". error message: " + csv_parser.err_message_);
......
......@@ -95,7 +95,7 @@ class CsvOp : public ParallelOp {
void setEndOffset(int64_t end_offset) { end_offset_ = end_offset; }
int processMessage(char c) {
int processMessage(int c) {
Message m = getMessage(c);
StateDiagram::iterator it = sd.find({cur_state_, m});
if (it == sd.end()) {
......@@ -132,7 +132,7 @@ class CsvOp : public ParallelOp {
typedef std::pair<State, std::function<int(CsvParser &, char)>> StateActionPair;
typedef std::map<StateMessagePair, StateActionPair> StateDiagram;
Message getMessage(char c) {
Message getMessage(int c) {
if (c == csv_field_delim_) {
return Message::MS_DELIM;
} else if (c == '"') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册