本文整理汇总了C++中ObObj::deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::deserialize方法的具体用法?C++ ObObj::deserialize怎么用?C++ ObObj::deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::deserialize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: free
TEST(ObObj,Serialize_int_add)
{
ObObj t;
t.set_int(9900);
int64_t len = t.get_serialize_size();
ASSERT_EQ(len,3);
char *buf = (char *)malloc(len);
int64_t pos = 0;
ASSERT_EQ(t.serialize(buf,len,pos),OB_SUCCESS);
ASSERT_EQ(pos,len);
ObObj f;
pos = 0;
ASSERT_EQ(f.deserialize(buf,len,pos),OB_SUCCESS);
ASSERT_EQ(pos,len);
int64_t r = 0;
int64_t l = 0;
ASSERT_EQ(f.get_type(),t.get_type());
f.get_int(r);
t.get_int(l);
ASSERT_EQ(r,l);
free(buf);
}
示例2: get_rowkey_compatible
int get_rowkey_compatible(const char* buf, const int64_t buf_len, int64_t & pos,
const ObRowkeyInfo& info, ObObj* array, int64_t& size, bool& is_binary_rowkey)
{
int ret = OB_SUCCESS;
ObObj obj;
int64_t obj_count = 0;
ObString str_value;
is_binary_rowkey = false;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos)) )
{
if (ObIntType == obj.get_type() && (OB_SUCCESS == (ret = obj.get_int(obj_count))))
{
// new rowkey format.
for (int64_t i = 0; i < obj_count && OB_SUCCESS == ret; ++i)
{
if (i >= size)
{
ret = OB_SIZE_OVERFLOW;
}
else
{
ret = array[i].deserialize(buf, buf_len, pos);
}
}
if (OB_SUCCESS == ret) size = obj_count;
}
else if (ObVarcharType == obj.get_type() && OB_SUCCESS == (ret = obj.get_varchar(str_value)))
{
is_binary_rowkey = true;
// old fashion , binary rowkey stream
if (size < info.get_size())
{
TBSYS_LOG(WARN, "input size=%ld not enough, need rowkey obj size=%ld", size, info.get_size());
ret = OB_SIZE_OVERFLOW;
}
else if (str_value.length() == 0)
{
// allow empty binary rowkey , incase min, max range.
size = 0;
}
else if (str_value.length() < info.get_binary_rowkey_length())
{
TBSYS_LOG(WARN, "binary rowkey length=%d < need rowkey length=%ld",
str_value.length(), info.get_binary_rowkey_length());
ret = OB_SIZE_OVERFLOW;
}
else
{
size = info.get_size();
ret = ObRowkeyHelper::binary_rowkey_to_obj_array(info, str_value, array, size);
}
}
}
return ret;
}
示例3: get_str_obj_value
int get_str_obj_value(const char* buf, const int64_t buf_len, int64_t & pos, ObString & str_value)
{
int ret = OB_SUCCESS;
ObObj obj;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos))
&& ObVarcharType == obj.get_type())
{
ret = obj.get_varchar(str_value);
}
return ret;
}
示例4: get_int_obj_value
int get_int_obj_value(const char* buf, const int64_t buf_len, int64_t & pos, int64_t & int_value)
{
int ret = OB_SUCCESS;
ObObj obj;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos))
&& ObIntType == obj.get_type())
{
ret = obj.get_int(int_value);
}
return ret;
}
示例5: deserialize_reserve_param
int ObReadParam::deserialize_reserve_param(const char * buf, const int64_t data_len, int64_t & pos)
{
ObObj obj;
int64_t int_value = 0;
int ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read master
set_is_read_consistency(int_value);
}
}
return ret;
}
示例6:
TEST(ObObj, test_bug)
{
ObObj obj;
obj.set_int(100, false);
char buf[2048];
int64_t len = 2048;
int64_t pos = 0;
ASSERT_EQ(obj.serialize(buf, len, pos), OB_SUCCESS);
pos = 0;
ObObj temp;
temp.set_int(200, true);
temp.reset();
ASSERT_EQ(temp.deserialize(buf, len, pos), OB_SUCCESS);
ASSERT_EQ(temp == obj, true);
ObObj test;
test.set_int(300, true);
test = temp;
ASSERT_EQ(test == temp, true);
}
示例7: deserialize_int
int ObSqlGetParam::deserialize_int(const char* buf, const int64_t data_len, int64_t& pos,
int64_t& value) const
{
int ret = OB_SUCCESS;
ObObjType type = ObNullType;
ObObj obj;
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
type = obj.get_type();
if (ObIntType == type)
{
obj.get_int(value);
}
else
{
TBSYS_LOG(WARN, "expected deserialize int type, but get type=%d", type);
ret = OB_ERROR;
}
}
return ret;
}
示例8: deserialize_basic_param
int ObSqlReadParam::deserialize_basic_param(const char * buf, const int64_t data_len, int64_t & pos)
{
ObObj obj;
int ret = OB_SUCCESS;
int64_t int_value = 0;
// read consistency
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read consistency
set_is_read_consistency(int_value);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// result cached
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read consistency
set_is_result_cached(int_value > 0);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// data_version
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
// data version
set_data_version(int_value);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// table id
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
table_id_ = int_value;
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// renamed table id
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
//.........这里部分代码省略.........