Ejemplo n.º 1
0
    int ObTabletInfo::deep_copy(CharArena &allocator, const ObTabletInfo &other, bool new_start_key, bool new_end_key)
    {
      int ret = OB_SUCCESS;
      
      this->row_count_ = other.row_count_;
      this->occupy_size_ = other.occupy_size_;
      this->crc_sum_ = other.crc_sum_;
      this->range_.table_id_ = other.range_.table_id_;
      this->range_.border_flag_ = other.range_.border_flag_;


      if (new_start_key) 
      {
        common::ObString::obstr_size_t sk_len = other.range_.start_key_.length();
        char* sk = reinterpret_cast<char*>(allocator.alloc(sk_len));
        if (NULL == sk)
        {
          ret = OB_ALLOCATE_MEMORY_FAILED;
          TBSYS_LOG(ERROR, "no memory");
        }
        else
        {
          memcpy(sk, other.range_.start_key_.ptr(), sk_len);
          this->range_.start_key_.assign(sk, sk_len);
        }
      }
      else
      {
        this->range_.start_key_ = other.range_.start_key_;
      }

      if (new_end_key)
      {
        common::ObString::obstr_size_t ek_len = other.range_.end_key_.length();
        char* ek = reinterpret_cast<char*>(allocator.alloc(ek_len));
        if (NULL == ek)
        {
          ret = OB_ALLOCATE_MEMORY_FAILED;
          TBSYS_LOG(ERROR, "no memory");
        }
        else
        {
          memcpy(ek, other.range_.end_key_.ptr(), ek_len);
          this->range_.end_key_.assign(ek, ek_len);
        }
      }
      else
      {
        this->range_.end_key_ = other.range_.end_key_;
      }
      return ret;
    }
Ejemplo n.º 2
0
void create_range(
    CharArena& allocator,
    ObRange &range,
    uint64_t table_id, 
    const int8_t flag, 
    const char* sk, 
    const char* ek)
{
  range.table_id_ = table_id;
  range.border_flag_.set_data(flag);
  int64_t sz = strlen(sk);
  char* msk = allocator.alloc(sz);
  memcpy(msk, sk, sz);
  range.start_key_.assign_ptr(msk, sz);
  sz = strlen(ek);
  char* mek = allocator.alloc(sz);
  memcpy(mek, ek, sz);
  range.end_key_.assign_ptr(mek, sz);
}
void create_row_key(
    CharArena& allocator,
    ObString& rowkey,
    const char* sk)
{
    int64_t sz = strlen(sk);
    char* msk = allocator.alloc(sz);
    memcpy(msk, sk, sz);
    rowkey.assign_ptr(msk, sz);
}