摘要:
记录获取数据的处理
架构设计:
类图:
时序图:
源码处理:
RCAttr::GetNotNullValueString
types::BString RCAttr::GetNotNullValueString(const int64_t obj) {
int pack = row2pack(obj);
int offset = row2offset(obj);
static const types::BString void_bs;
if (GetPackType() == common::PackType::STR) {
auto cur_pack = get_packS(pack);
if (!cur_pack) {
// TIANMU_LOG(LogCtl_Level::INFO, "rc_attr:GetNotNullValueString get_packS NULL, obj: %d pack: %d offset: %d", obj,
// pack, offset);
return void_bs;
}
uint64_t p = reinterpret_cast<uint64_t>(cur_pack);
if (0xffffffffffff == p) {
return void_bs;
}
ASSERT(cur_pack != NULL, "Pack ptr is null");
ASSERT(cur_pack->IsLocked(), "Access unlocked pack");
return cur_pack->GetValueBinary(offset);
}
int64_t v = GetNotNullValueInt64(obj);
return DecodeValue_S(v);
}
RCAttr::get_pack
Pack *RCAttr::get_pack(size_t i) { return reinterpret_cast<Pack *>(get_dpn(i).GetPackPtr() & tag_mask); }
RCAttr::get_dpn
DPN &get_dpn(size_t i) {
ASSERT(i < m_idx.size(), "bad dpn index " + std::to_string(i) + "/" + std::to_string(m_idx.size()));
return *m_share->get_dpn_ptr(m_idx[i]);
}
ColumnShare::get_dpn_ptr
DPN *get_dpn_ptr(common::PACK_INDEX i) {
ASSERT(i < common::COL_DN_FILE_SIZE / sizeof(DPN), "bad dpn index: " + std::to_string(i));
return &start[i];
}
DPN *start;
DPN::GetPackPtr
uint64_t GetPackPtr() const { return tagged_ptr.load(); }
// a tagged pointer, 16 bits as ref count.
// Only read-only dpn uses it for ref counting; local dpn is managed only by
// one write session
std::atomic_ulong tagged_ptr;