提交 b7a5e349 编写于 作者: L lx0 提交者: LINGuanRen

Add sanity_check API for ObNumber

上级 f935bcf9
......@@ -184,6 +184,24 @@ public:
// v2: algorithmic optimization edition
// v3: engineering optimization edition
int sanity_check()
{
int ret = OB_SUCCESS;
if (d_.len_ > OB_MAX_DECIMAL_DIGIT) {
ret = OB_ERR_UNEXPECTED;
_OB_LOG(WARN, "Invalid digit len %u", d_.len_);
} else if (d_.len_ > 0 && digits_ != nullptr) {
for (auto i = 0; OB_SUCC(ret) && i < d_.len_; i++) {
if (digits_[i] >= BASE) {
ret = OB_ERR_UNEXPECTED;
_OB_LOG(WARN, "Invalid value %u", digits_[i]);
} else {
_OB_LOG(DEBUG, "Digit value %u", digits_[i]);
}
}
}
return ret;
}
template <class T>
int from(const int64_t value, T& allocator);
template <class T>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册