当前位置: 首页>>代码示例>>C++>>正文


C++ ObDataBuffer::get_remain方法代码示例

本文整理汇总了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;
    }
开发者ID:Abioy,项目名称:oceanbase,代码行数:33,代码来源:ob_client_manager.cpp

示例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;
}
开发者ID:CCoder123,项目名称:pproj,代码行数:8,代码来源:db_utils.cpp

示例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;
}
开发者ID:CCoder123,项目名称:pproj,代码行数:12,代码来源:db_utils.cpp

示例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;
    }
开发者ID:Abioy,项目名称:oceanbase,代码行数:64,代码来源:ob_client_manager.cpp

示例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;
  }

//.........这里部分代码省略.........
开发者ID:CCoder123,项目名称:pproj,代码行数:101,代码来源:db_utils.cpp


注:本文中的ObDataBuffer::get_remain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。