int ob_cast_rowkey(const ObRowkeyInfo &rowkey_info, ObRowkey &rowkey, char* buf, int64_t buf_size, int64_t &used_buf_len) { int ret = OB_SUCCESS; used_buf_len = 0; if (OB_UNLIKELY(rowkey_info.get_size() != rowkey.get_obj_cnt())) { TBSYS_LOG(ERROR, "wrong rowkey length, rowkey_info_len=%ld rowkey_len=%ld", rowkey_info.get_size(), rowkey.get_obj_cnt()); ret = OB_ERR_UNEXPECTED; } else { int64_t used_len = 0; for (int64_t i = 0; i < rowkey.get_obj_cnt(); ++i) { ObObj &cell = const_cast<ObObj&>(rowkey.get_obj_ptr()[i]); ObObjType to_type = rowkey_info.get_column(i)->type_; if (OB_SUCCESS != (ret = obj_cast(cell, to_type, buf+used_buf_len, buf_size-used_buf_len, used_len))) { TBSYS_LOG(WARN, "failed to cast obj, i=%ld", i); break; } else { used_buf_len += used_len; } } // end for } return ret; }
int obj_cast(ObObj &cell, const ObObjType expected_type, string &cast_buffer) { int64_t used_buf_len = 0; return obj_cast(cell, expected_type, (char*) cast_buffer.data(), cast_buffer.length(), used_buf_len); }