imay commented on a change in pull request #1173: load data from Parquet file
(Issues #911)
URL: https://github.com/apache/incubator-doris/pull/1173#discussion_r289273867
##########
File path: be/src/exec/local_file_reader.cpp
##########
@@ -37,52 +39,78 @@ Status LocalFileReader::open() {
return Status(ss.str());
}
- if (_start_offset != 0) {
- int res = fseek(_fp, _start_offset, SEEK_SET);
- if (res != 0) {
- char err_buf[64];
- std::stringstream ss;
- ss << "Seek to start_offset failed. offset=" << _start_offset
- << ", error=" << strerror_r(errno, err_buf, 64);
- return Status(ss.str());
- }
+ return seek(_current_offset);
+}
+
+void LocalFileReader::close() {
+ if (_fp != nullptr) {
+ fclose(_fp);
+ _fp = nullptr;
}
+}
- return Status::OK;
+bool LocalFileReader::closed() {
+ return _fp == nullptr;
}
Status LocalFileReader::read(uint8_t* buf, size_t* buf_len, bool* eof) {
- if (_eof) {
- *buf_len = 0;
+ readat(_current_offset, (int64_t)*buf_len, (int64_t*)buf_len, buf);
+ if (*buf_len == 0) {
*eof = true;
- return Status::OK;
+ } else {
+ *eof = false;
}
- size_t read_len = fread(buf, 1, *buf_len, _fp);
- if (read_len < *buf_len) {
- if (ferror(_fp)) {
- char err_buf[64];
- std::stringstream ss;
- ss << "Read file failed. path=" << _path
- << ", error=" << strerror_r(errno, err_buf, 64);
- return Status(ss.str());
- } else if (feof(_fp)) {
- *buf_len = read_len;
- _eof = true;
- if (*buf_len == 0) {
- *eof = true;
- }
- } else {
- return Status("Unknown read failed.");
- }
+ return Status::OK;
+}
+
+Status LocalFileReader::readat(int64_t position, int64_t nbytes, int64_t*
bytes_read, void* out) {
+ if (position != _current_offset) {
+ fseek(_fp, position, SEEK_SET);
Review comment:
you should check fseek's result
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]