1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-5206 This patch brings some EMIndex and treeish EM leftovers from develop-5

This commit is contained in:
Roman Nozdrin
2022-08-24 18:55:53 +00:00
parent fabb975b8a
commit c049d85d63
3 changed files with 45 additions and 74 deletions

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc. /* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016-2022 MariaDB Corporation
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of as published by the Free Software Foundation; version 2 of
@ -295,6 +295,9 @@ class LBIDRange : public messageqcpp::Serializeable
uint32_t size; uint32_t size;
EXPORT LBIDRange(); EXPORT LBIDRange();
LBIDRange(const LBID_t aStart, const uint32_t aSize) : start(aStart), size(aSize)
{
}
EXPORT LBIDRange(const LBIDRange& l); EXPORT LBIDRange(const LBIDRange& l);
EXPORT LBIDRange(const InlineLBIDRange& l); EXPORT LBIDRange(const InlineLBIDRange& l);
EXPORT LBIDRange& operator=(const LBIDRange& l); EXPORT LBIDRange& operator=(const LBIDRange& l);

View File

@ -2471,17 +2471,15 @@ int ExtentMap::lookupLocal_DBroot(int OID, uint16_t dbroot, uint32_t partitionNu
grabEMEntryTable(READ); grabEMEntryTable(READ);
grabEMIndex(READ); grabEMIndex(READ);
for (auto emIt = fExtentMapRBTree->begin(), end = fExtentMapRBTree->end(); emIt != end; ++emIt) const auto lbids = fPExtMapIndexImpl_->find(dbroot, OID, partitionNum);
const auto emIdents = getEmIdentsByLbids(lbids);
for (auto& emEntry : emIdents)
{ {
const auto& emEntry = emIt->second; if (emEntry.segmentNum == segmentNum && emEntry.blockOffset <= fileBlockOffset &&
// TODO: Blockoffset logic.
if (emEntry.fileID == OID && emEntry.dbRoot == dbroot && emEntry.partitionNum == partitionNum &&
emEntry.segmentNum == segmentNum && emEntry.blockOffset <= fileBlockOffset &&
fileBlockOffset <= (emEntry.blockOffset + (static_cast<LBID_t>(emEntry.range.size) * 1024) - 1)) fileBlockOffset <= (emEntry.blockOffset + (static_cast<LBID_t>(emEntry.range.size) * 1024) - 1))
{ {
auto offset = fileBlockOffset - emEntry.blockOffset; auto offset = fileBlockOffset - emEntry.blockOffset;
LBID = emEntry.range.start + offset; LBID = emEntry.range.start + offset;
releaseEMIndex(READ); releaseEMIndex(READ);
releaseEMEntryTable(READ); releaseEMEntryTable(READ);
return 0; return 0;
@ -3325,7 +3323,6 @@ LBID_t ExtentMap::_createColumnExtentExactFile(uint32_t size, int OID, uint32_t
newEmEntry.segmentNum = segmentNum; newEmEntry.segmentNum = segmentNum;
newEmEntry.status = EXTENTUNAVAILABLE; // mark extent as in process newEmEntry.status = EXTENTUNAVAILABLE; // mark extent as in process
if (isUnsigned(colDataType)) if (isUnsigned(colDataType))
{ {
if (colWidth != datatypes::MAXDECIMALWIDTH) if (colWidth != datatypes::MAXDECIMALWIDTH)
@ -3670,8 +3667,6 @@ void ExtentMap::printFL() const
void ExtentMap::rollbackColumnExtents_DBroot(int oid, bool bDeleteAll, uint16_t dbRoot, uint32_t partitionNum, void ExtentMap::rollbackColumnExtents_DBroot(int oid, bool bDeleteAll, uint16_t dbRoot, uint32_t partitionNum,
uint16_t segmentNum, HWM_t hwm) uint16_t segmentNum, HWM_t hwm)
{ {
// bool oidExists = false;
#ifdef BRM_INFO #ifdef BRM_INFO
if (fDebug) if (fDebug)
{ {
@ -3810,6 +3805,7 @@ void ExtentMap::rollbackColumnExtents_DBroot(int oid, bool bDeleteAll, uint16_t
} }
} }
} }
// If this function is called, we are already in error recovery mode; so // If this function is called, we are already in error recovery mode; so
// don't worry about reporting an error if the OID is not found, because // don't worry about reporting an error if the OID is not found, because
// we don't want/need the extents for that OID anyway. // we don't want/need the extents for that OID anyway.
@ -3851,8 +3847,6 @@ void ExtentMap::rollbackColumnExtents_DBroot(int oid, bool bDeleteAll, uint16_t
void ExtentMap::rollbackDictStoreExtents_DBroot(int oid, uint16_t dbRoot, uint32_t partitionNum, void ExtentMap::rollbackDictStoreExtents_DBroot(int oid, uint16_t dbRoot, uint32_t partitionNum,
const vector<uint16_t>& segNums, const vector<HWM_t>& hwms) const vector<uint16_t>& segNums, const vector<HWM_t>& hwms)
{ {
// bool oidExists = false;
#ifdef BRM_INFO #ifdef BRM_INFO
if (fDebug) if (fDebug)
{ {
@ -3980,20 +3974,6 @@ void ExtentMap::rollbackDictStoreExtents_DBroot(int oid, uint16_t dbRoot, uint32
} }
} }
} }
// If this function is called, we are already in error recovery mode; so
// don't worry about reporting an error if the OID is not found, because
// we don't want/need the extents for that OID anyway.
// if (!oidExists)
//{
// ostringstream oss;
// oss << "ExtentMap::rollbackDictStoreExtents_DBroot(): "
// "Rollback failed: no extents exist for: OID-" << oid <<
// "; dbRoot-" << dbRoot <<
// "; partition-" << partitionNum;
// log(oss.str(), logging::LOG_TYPE_CRITICAL);
// throw invalid_argument(oss.str());
//}
} }
} }
@ -4271,6 +4251,7 @@ void ExtentMap::deleteOID(int OID)
// Clean up the index and tell deleteExtent to skip the clean-up. // Clean up the index and tell deleteExtent to skip the clean-up.
DBRootVec dbRootVec(getAllDbRoots()); DBRootVec dbRootVec(getAllDbRoots());
for (auto dbRoot : dbRootVec) for (auto dbRoot : dbRootVec)
{ {
const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID); const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID);
@ -4504,14 +4485,12 @@ HWM_t ExtentMap::getLastHWM_DBroot(int OID, uint16_t dbRoot, uint32_t& partition
log(oss.str(), logging::LOG_TYPE_CRITICAL); log(oss.str(), logging::LOG_TYPE_CRITICAL);
throw invalid_argument(oss.str()); throw invalid_argument(oss.str());
} }
grabEMEntryTable(READ); grabEMEntryTable(READ);
grabEMIndex(READ); grabEMIndex(READ);
const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID); const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID);
const auto emIdents = getEmIdentsByLbids(lbids); const auto emIdents = getEmIdentsByLbids(lbids);
auto lastEmEntry = emIdents.begin(); auto lastEmEntry = emIdents.begin();
for (auto emEntry = emIdents.begin(); emEntry < emIdents.end(); ++emEntry) for (auto emEntry = emIdents.begin(); emEntry < emIdents.end(); ++emEntry)
{ {
if (((emEntry->status == EXTENTAVAILABLE) || (emEntry->status == EXTENTOUTOFSERVICE)) && if (((emEntry->status == EXTENTAVAILABLE) || (emEntry->status == EXTENTOUTOFSERVICE)) &&
@ -4595,7 +4574,6 @@ void ExtentMap::getDbRootHWMInfo(int OID, uint16_t pmNumber, EmDbRootHWMInfo_v&
grabEMEntryTable(READ); grabEMEntryTable(READ);
grabEMIndex(READ); grabEMIndex(READ);
tr1::unordered_map<uint16_t, EmDbRootHWMInfo>::iterator emIter; tr1::unordered_map<uint16_t, EmDbRootHWMInfo>::iterator emIter;
// Indicates that we found an extent, the index itself means nothing. // Indicates that we found an extent, the index itself means nothing.
// TODO: Update to flag. // TODO: Update to flag.
uint32_t foundIndex = 0; uint32_t foundIndex = 0;
@ -4787,6 +4765,7 @@ HWM_t ExtentMap::getLocalHWM(int OID, uint32_t partitionNum, uint16_t segmentNum
grabEMIndex(READ); grabEMIndex(READ);
DBRootVec dbRootVec(getAllDbRoots()); DBRootVec dbRootVec(getAllDbRoots());
for (auto dbRoot : dbRootVec) for (auto dbRoot : dbRootVec)
{ {
const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID, partitionNum); const auto lbids = fPExtMapIndexImpl_->find(dbRoot, OID, partitionNum);
@ -4950,7 +4929,6 @@ void ExtentMap::setLocalHWM(int OID, uint32_t partitionNum, uint16_t segmentNum,
log(os.str(), logging::LOG_TYPE_DEBUG); log(os.str(), logging::LOG_TYPE_DEBUG);
} }
#endif #endif
} }
@ -5089,7 +5067,6 @@ void ExtentMap::getExtents_dbroot(int OID, vector<struct EMEntry>& entries, cons
#endif #endif
entries.clear(); entries.clear();
if (OID < 0) if (OID < 0)
{ {
ostringstream oss; ostringstream oss;
@ -5237,7 +5214,6 @@ void ExtentMap::deletePartition(const set<OID_t>& oids, const set<LogicalPartiti
std::set<LogicalPartition> foundPartitions; std::set<LogicalPartition> foundPartitions;
std::vector<ExtentMapRBTree::iterator> extents; std::vector<ExtentMapRBTree::iterator> extents;
for (auto oid : oids) for (auto oid : oids)
{ {
for (auto& partition : partitionNums) for (auto& partition : partitionNums)
@ -5297,7 +5273,6 @@ void ExtentMap::markPartitionForDeletion(const set<OID_t>& oids, const set<Logic
string& emsg) string& emsg)
{ {
#ifdef BRM_INFO #ifdef BRM_INFO
if (fDebug) if (fDebug)
{ {
TRACER_WRITENOW("markPartitionForDeletion"); TRACER_WRITENOW("markPartitionForDeletion");
@ -5487,7 +5462,6 @@ void ExtentMap::restorePartition(const set<OID_t>& oids, const set<LogicalPartit
if (oids.size() == 0) if (oids.size() == 0)
return; return;
set<OID_t>::const_iterator it;
grabEMEntryTable(WRITE); grabEMEntryTable(WRITE);
grabEMIndex(WRITE); grabEMIndex(WRITE);
@ -5734,12 +5708,7 @@ void ExtentMap::lookup(OID_t OID, LBIDRange_v& ranges)
for (auto& emEntry : emIdents) for (auto& emEntry : emIdents)
{ {
if (emEntry.status != EXTENTOUTOFSERVICE) if (emEntry.status != EXTENTOUTOFSERVICE)
{ ranges.emplace_back(emEntry.range.start, emEntry.range.size * 1024);
LBIDRange tmp;
tmp.start = emEntry.range.start;
tmp.size = emEntry.range.size * 1024;
ranges.emplace_back(tmp);
}
} }
} }

View File

@ -1066,11 +1066,10 @@ class ExtentMap : public Undoable
static const constexpr size_t EM_FREELIST_INITIAL_SIZE = 50 * sizeof(InlineLBIDRange); static const constexpr size_t EM_FREELIST_INITIAL_SIZE = 50 * sizeof(InlineLBIDRange);
static const constexpr size_t EM_FREELIST_INCREMENT = 50 * sizeof(InlineLBIDRange); static const constexpr size_t EM_FREELIST_INCREMENT = 50 * sizeof(InlineLBIDRange);
// RBTree constants. // RBTree constants.
static const size_t EM_RB_TREE_NODE_SIZE = 10 * (sizeof(EMEntry) + 8 * sizeof(uint64_t)); static const size_t EM_RB_TREE_NODE_SIZE = sizeof(EMEntry) + 8 * sizeof(uint64_t);
static const size_t EM_RB_TREE_EMPTY_SIZE = 1024; static const size_t EM_RB_TREE_EMPTY_SIZE = 1024;
static const size_t EM_RB_TREE_INITIAL_SIZE = static const size_t EM_RB_TREE_INITIAL_SIZE = 16 * 1024 * 1024;
EM_INCREMENT_ROWS * 10 * EM_RB_TREE_NODE_SIZE + EM_RB_TREE_EMPTY_SIZE; static const size_t EM_RB_TREE_INCREMENT = 16 * 1024 * 1024;
static const size_t EM_RB_TREE_INCREMENT = EM_INCREMENT_ROWS * EM_RB_TREE_NODE_SIZE;
ExtentMap(const ExtentMap& em); ExtentMap(const ExtentMap& em);
ExtentMap& operator=(const ExtentMap& em); ExtentMap& operator=(const ExtentMap& em);