本文整理汇总了C++中ObDataBuffer::get_remain方法的典型用法代码示例。如果您正苦于以下问题:C++ ObDataBuffer::get_remain方法的具体用法?C++ ObDataBuffer::get_remain怎么用?C++ ObDataBuffer::get_remain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObDataBuffer
的用法示例。
在下文中一共展示了ObDataBuffer::get_remain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_request
int ObClientManager::send_request(const ObServer& server, const int32_t pcode, const int32_t version,
const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer, int64_t& session_id) const
{
int rc = OB_SUCCESS;
ObPacket* response = NULL;
rc = do_send_request(server, pcode, version, timeout, in_buffer, response);
// deserialize response packet to out_buffer
if (OB_SUCCESS == rc && NULL != response)
{
session_id = response->get_session_id() ; // TODO
// copy response's inner_buffer to out_buffer.
int64_t data_length = response->get_data_length();
ObDataBuffer* response_buffer = response->get_buffer();
if (out_buffer.get_remain() < data_length)
{
TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
out_buffer.get_remain(), data_length);
rc = OB_ERROR;
}
else
{
memcpy(out_buffer.get_data() + out_buffer.get_position(),
response_buffer->get_data() + response_buffer->get_position(),
data_length);
out_buffer.get_position() += data_length;
}
}
return rc;
}
示例2: append_header_delima
int append_header_delima(ObDataBuffer &buff)
{
if (buff.get_remain() < 1)
return OB_ERROR;
buff.get_data()[buff.get_position()++] = header_delima;
return OB_SUCCESS;
}
示例3: append_end_rec
int append_end_rec(ObDataBuffer &buff)
{
char *data = buff.get_data();
int64_t pos = buff.get_position();
int64_t cap = buff.get_remain();
int len = snprintf(data + pos, cap, "\n");
if (len >=0 )
buff.get_position() += len;
return len;
}
示例4: get_next
int ObClientManager::get_next(const ObServer& server, const int64_t session_id,
const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer) const
{
int rc = OB_SUCCESS;
ObPacket* response = NULL;
//rc = send_request(server, pcode, version, timeout, in_buffer, response);
ObPacket* packet = new (std::nothrow) ObPacket();
if (NULL == packet)
{
rc = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
packet->set_packet_code(OB_SESSION_NEXT_REQUEST);
packet->setChannelId(0);
packet->set_api_version(0);
packet->set_data(in_buffer);
packet->set_source_timeout(timeout);
packet->set_session_id(session_id); //TODO
}
if (OB_SUCCESS == rc)
{
rc = packet->serialize();
if (OB_SUCCESS != rc)
TBSYS_LOG(WARN, "packet serialize error, code=%d", packet->get_packet_code());
}
// serialize failed
if (OB_SUCCESS != rc && NULL != packet)
{
packet->free();
}
if (OB_SUCCESS == rc)
{
rc = do_send_packet(server, packet, timeout, response);
}
// deserialize response packet to out_buffer
if (OB_SUCCESS == rc && NULL != response)
{
// copy response's inner_buffer to out_buffer.
int64_t data_length = response->get_data_length();
ObDataBuffer* response_buffer = response->get_buffer();
if (out_buffer.get_remain() < data_length)
{
TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
out_buffer.get_remain(), data_length);
rc = OB_ERROR;
}
else
{
memcpy(out_buffer.get_data() + out_buffer.get_position(),
response_buffer->get_data() + response_buffer->get_position(),
data_length);
out_buffer.get_position() += data_length;
}
}
return rc;
}
示例5: serialize_cell
int serialize_cell(ObCellInfo *cell, ObDataBuffer &buff)
{
int64_t cap = buff.get_remain();
int64_t len = -1;
int type = cell->value_.get_type();
char *data = buff.get_data();
int64_t pos = buff.get_position();
switch(type) {
case ObNullType:
// TBSYS_LOG(INFO, "Null Type");
len = 0;
break;
case ObIntType:
int64_t val;
if (cell->value_.get_int(val) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_int error");
break;
}
len = snprintf(data + pos, cap, "%ld", val);
break;
case ObVarcharType:
{
ObString str;
if (cell->value_.get_varchar(str) != OB_SUCCESS ||
cap < str.length()) {
TBSYS_LOG(ERROR, "get_varchar error");
break;
}
memcpy(data + pos, str.ptr(), str.length());
escape_varchar(data + pos, str.length());
len = str.length();
}
break;
case ObPreciseDateTimeType:
{
int64_t value;
if (cell->value_.get_precise_datetime(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_precise_datetime error");
break;
}
len = ObDateTime2MySQLDate(value, type, data + pos, cap);
}
break;
case ObDateTimeType:
{
int64_t value;
if (cell->value_.get_datetime(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_datetime error ");
break;
}
len = ObDateTime2MySQLDate(value, type, data + pos, cap);
}
break;
case ObModifyTimeType:
{
int64_t value;
if (cell->value_.get_modifytime(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_modifytime error ");
break;
}
len = ObDateTime2MySQLDate(value, type, data + pos, cap);
}
break;
case ObCreateTimeType:
{
int64_t value;
if (cell->value_.get_createtime(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_createtime error");
break;
}
len = ObDateTime2MySQLDate(value, type, data + pos, cap);
}
break;
case ObFloatType:
{
float value;
if (cell->value_.get_float(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_float error");
break;
}
len = snprintf(data + pos, cap, "%f", value);
}
break;
case ObDoubleType:
{
double value;
if (cell->value_.get_double(value) != OB_SUCCESS) {
TBSYS_LOG(ERROR, "get_double error");
break;
}
len = snprintf(data + pos, cap, "%f", value);
}
break;
default:
TBSYS_LOG(WARN, "Not Defined Type %d", cell->value_.get_type());
break;
}
//.........这里部分代码省略.........