本文整理汇总了C++中ObString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ObString::size方法的具体用法?C++ ObString::size怎么用?C++ ObString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObString
的用法示例。
在下文中一共展示了ObString::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
int ObUpsRowUtil::convert(const ObUpsRow &row, ObString &compact_row)
{
int ret = OB_SUCCESS;
ObCompactCellWriter cell_writer;
cell_writer.init(compact_row.ptr(), compact_row.size());
const ObObj *cell = NULL;
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
ObObj cell_clone;
if(row.get_is_delete_row())
{
if(OB_SUCCESS != (ret = cell_writer.row_delete()))
{
TBSYS_LOG(WARN, "append delete row fail:ret[%d]", ret);
}
}
for (int64_t i = 0; (OB_SUCCESS == ret) && i < row.get_column_num(); ++i)
{
if (OB_SUCCESS != (ret = row.raw_get_cell(i, cell, table_id, column_id)))
{
TBSYS_LOG(WARN, "failed to get cell, err=%d", ret);
break;
}
else
{
if(ObExtendType == cell->get_type() && ObActionFlag::OP_NOP == cell->get_ext())
{
//不用处理,OP_NOP不序列化
}
else if (OB_SUCCESS != (ret = cell_writer.append(column_id, *cell)))
{
if (OB_SIZE_OVERFLOW != ret)
{
TBSYS_LOG(WARN, "failed to append cell, err=%d", ret);
}
break;
}
}
} // end for i
if (OB_SUCCESS == ret)
{
if (OB_SUCCESS != (ret = cell_writer.row_finish()))
{
if (OB_SIZE_OVERFLOW != ret)
{
TBSYS_LOG(WARN, "failed to append cell, err=%d", ret);
}
}
else
{
compact_row.assign_ptr(compact_row.ptr(), (int32_t)(cell_writer.size()));
}
}
return ret;
}
示例2: update_all_cluster
int ObInnerTableOperator::update_all_cluster(ObString & sql, const int64_t cluster_id,
const ObServer & server, const ObiRole role, const int64_t flow_percent)
{
int ret = OB_SUCCESS;
if ((sql.ptr() == NULL) || (0 == sql.size()))
{
ret = OB_INVALID_ARGUMENT;
TBSYS_LOG(WARN, "Check SQL buffer size failed! ptr[%p], size[%d]", sql.ptr(), sql.size());
}
else
{
char buf[OB_MAX_SERVER_ADDR_SIZE];
memset(buf, 0 , sizeof(buf));
if (server.ip_to_string(buf, sizeof(buf)) != true)
{
ret = OB_CONVERT_ERROR;
TBSYS_LOG(ERROR, "server ip is invalid, ret=%d", ret);
}
else
{
const char * format = "REPLACE INTO %s"
"(cluster_id, cluster_role, cluster_vip, cluster_flow_percent, read_strategy, rootserver_port) "
"VALUES(%d,%d,'%s',%d,%d,%d);";
// random read read_strategy
int size = snprintf(sql.ptr(), sql.size(), format, OB_ALL_CLUSTER, cluster_id,
role.get_role() == ObiRole::MASTER ? 1 : 2, buf, flow_percent, 0, server.get_port());
if (size >= sql.size())
{
TBSYS_LOG(ERROR, "SQL buffer size not enough! size: [%d], need: [%d], sql: [%.*s]",
sql.size(), size, sql.length(), sql.ptr());
ret = OB_SIZE_OVERFLOW;
}
else
{
sql.assign_ptr(sql.ptr(), size);
TBSYS_LOG(INFO, "XXX=%.*s", sql.length(), sql.ptr());
}
}
}
return ret;
}
示例3: update_all_trigger_event
int ObInnerTableOperator::update_all_trigger_event(ObString & sql, const int64_t timestamp,
const ObServer & server, const int64_t type, const int64_t param)
{
UNUSED(param);
int ret = OB_SUCCESS;
if ((sql.ptr() == NULL) || (0 == sql.size()))
{
TBSYS_LOG(WARN, "Check SQL buffer size failed! ptr[%p], size[%d]", sql.ptr(), sql.size());
ret = OB_INVALID_ARGUMENT;
}
else
{
char buf[OB_MAX_SERVER_ADDR_SIZE] = "";
if (server.ip_to_string(buf, sizeof(buf)) != true)
{
ret = OB_CONVERT_ERROR;
}
else
{
const char * format = "REPLACE INTO %s"
"(event_ts, src_ip, event_type, event_param) "
"values (%ld, '%s', %ld, %ld);";
int size = snprintf(sql.ptr(), sql.size(), format,
OB_ALL_TRIGGER_EVENT_TABLE_NAME, timestamp, buf, type, param);
if (size >= sql.size())
{
TBSYS_LOG(ERROR, "SQL buffer size not enough! size: [%d], need: [%d], sql: [%.*s]",
sql.size(), size, sql.length(), sql.ptr());
ret = OB_SIZE_OVERFLOW;
}
else
{
sql.assign_ptr(sql.ptr(), size);
}
}
}
return ret;
}
示例4: update_all_server
int ObInnerTableOperator::update_all_server(ObString & sql, const int64_t cluster_id,
const char * server_type, const ObServer & server, const uint32_t inner_port, const char * version)
{
int ret = OB_SUCCESS;
if ((sql.ptr() == NULL) || (0 == sql.size()))
{
TBSYS_LOG(WARN, "Check SQL buffer size failed! ptr[%p], size[%d]", sql.ptr(), sql.size());
ret = OB_INVALID_ARGUMENT;
}
else
{
char buf[OB_MAX_SERVER_ADDR_SIZE] = "";
if (server.ip_to_string(buf, sizeof(buf)) != true)
{
ret = OB_CONVERT_ERROR;
}
else
{
const char * format = "REPLACE INTO %s"
"(cluster_id, svr_type, svr_ip, svr_port, inner_port, svr_role, svr_version) "
"values (%d, '%s', '%s', %u, %u, %d, '%s');";
int size = snprintf(sql.ptr(), sql.size(), format, OB_ALL_SERVER, cluster_id,
server_type, buf, server.get_port(), inner_port, 0, version);
if (size >= sql.size())
{
TBSYS_LOG(ERROR, "SQL buffer size not enough! size: [%d], need: [%d], sql: [%.*s]",
sql.size(), size, sql.length(), sql.ptr());
ret = OB_SIZE_OVERFLOW;
}
else
{
sql.assign_ptr(sql.ptr(), size);
}
}
}
return ret;
}
示例5: delete_all_server
int ObInnerTableOperator::delete_all_server(ObString & sql, const int64_t cluster_id,
const char * server_type, const ObServer & server)
{
int ret = OB_SUCCESS;
if ((sql.ptr() == NULL) || (0 == sql.size()))
{
TBSYS_LOG(WARN, "Check SQL buffer size failed! ptr[%p], size[%d]", sql.ptr(), sql.size());
ret = OB_INVALID_ARGUMENT;
}
else
{
char buf[OB_MAX_SERVER_ADDR_SIZE] = "";
if (server.ip_to_string(buf, sizeof (buf)) != true)
{
ret = OB_CONVERT_ERROR;
}
else
{
const char * format = "DELETE FROM %s WHERE cluster_id = %d AND svr_type = '%s' "
"AND svr_ip = '%s' AND svr_port = %u;";
int size = snprintf(sql.ptr(), sql.size(), format, OB_ALL_SERVER,
cluster_id, server_type, buf, server.get_port());
if (size >= sql.size())
{
TBSYS_LOG(ERROR, "SQL buffer size not enough! size: [%d], need: [%d], sql: [%.*s]",
sql.size(), size, sql.length(), sql.ptr());
ret = OB_SIZE_OVERFLOW;
}
else
{
sql.assign_ptr(sql.ptr(), size);
}
}
}
return ret;
}