int ObLocatedLogReader::read_log(const int64_t file_id, const int64_t offset, int64_t& start_id, int64_t& end_id, char* buf, const int64_t len, int64_t& read_count, bool& is_file_end) { int err = OB_SUCCESS; if (!is_inited()) { err = OB_NOT_INIT; } else if (OB_SUCCESS != (err = read_log_file_by_location(log_dir_, file_id, offset, buf, len, read_count, dio_))) { TBSYS_LOG(ERROR, "read_log_file_by_location(%s/%ld, offset=%ld)=>%d", log_dir_, file_id, offset, err); } else if (OB_SUCCESS != (err = trim_log_buffer(offset, OB_DIRECT_IO_ALIGN_BITS, buf, read_count, read_count, start_id, end_id, is_file_end))) { TBSYS_LOG(ERROR, "trim_log_buffer()=>%d", err); } return err; }
int ObLogBuffer::get_log(const int64_t align_bits, const int64_t pos, int64_t& real_pos, int64_t& start_id, int64_t& end_id, char* buf, const int64_t len, int64_t& read_count) const { int err = OB_SUCCESS; bool is_file_end = false; int64_t copy_count = 0; if (OB_SUCCESS != (err = check_state())) { TBSYS_LOG(ERROR, "check_state()=>%d", err); } else if (NULL == buf || len <= 0 || 0 > pos) { err = OB_INVALID_ARGUMENT; TBSYS_LOG(ERROR, "get_log(start_id=%ld, buf=%p[%ld]): invalid argument", start_id, buf, len); } else if (0 == start_id || (0 != end_id_ && start_id > end_id_)) { err = OB_DATA_NOT_SERVE; } else if (OB_SUCCESS != (err = read(pos, real_pos, buf, len, copy_count))) { if (OB_DATA_NOT_SERVE != err) { TBSYS_LOG(ERROR, "copy_to_buf(%p[%ld], read_count=%ld)=>%d", buf, len, read_count, err); } } else if (OB_SUCCESS != (err = trim_log_buffer(real_pos, align_bits, buf, copy_count, read_count, start_id, end_id, is_file_end))) { TBSYS_LOG(WARN, "parse_log_buffer(buf=%p[%ld], start_id=%ld)=>%d", buf, copy_count, start_id, err); } else if (copy_count > 0 && read_count <= 0) { err = OB_DATA_NOT_SERVE; TBSYS_LOG(ERROR, "get_log(start_id=%ld, copy_count=%ld, read_count=%ld): NOT find align pos", start_id, copy_count, read_count); } return err; }