You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-27 21:01:50 +03:00
clang format apply
This commit is contained in:
@ -33,7 +33,6 @@ using namespace boost::posix_time;
|
||||
|
||||
namespace BRM
|
||||
{
|
||||
|
||||
AutoincrementManager::AutoincrementManager()
|
||||
{
|
||||
}
|
||||
@ -43,118 +42,116 @@ AutoincrementManager::~AutoincrementManager()
|
||||
}
|
||||
|
||||
void AutoincrementManager::startSequence(uint32_t oid, uint64_t firstNum, uint32_t colWidth,
|
||||
execplan::CalpontSystemCatalog::ColDataType colDataType)
|
||||
execplan::CalpontSystemCatalog::ColDataType colDataType)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
sequence s;
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
sequence s;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it != sequences.end())
|
||||
return;
|
||||
if (it != sequences.end())
|
||||
return;
|
||||
|
||||
s.value = firstNum;
|
||||
s.value = firstNum;
|
||||
|
||||
if (isUnsigned(colDataType))
|
||||
{
|
||||
s.overflow = (0xFFFFFFFFFFFFFFFFULL >> (64 - colWidth * 8)) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.overflow = (1ULL << (colWidth * 8 - 1));
|
||||
}
|
||||
if (isUnsigned(colDataType))
|
||||
{
|
||||
s.overflow = (0xFFFFFFFFFFFFFFFFULL >> (64 - colWidth * 8)) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.overflow = (1ULL << (colWidth * 8 - 1));
|
||||
}
|
||||
|
||||
sequences[oid] = s;
|
||||
sequences[oid] = s;
|
||||
}
|
||||
|
||||
bool AutoincrementManager::getAIRange(uint32_t oid, uint64_t count, uint64_t* firstNum)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it == sequences.end())
|
||||
throw runtime_error("There is no sequence with that lock");
|
||||
if (it == sequences.end())
|
||||
throw runtime_error("There is no sequence with that lock");
|
||||
|
||||
if ((count >= it->second.overflow ||
|
||||
count + it->second.value > it->second.overflow ||
|
||||
count + it->second.value <= it->second.value)
|
||||
&& count != 0)
|
||||
return false;
|
||||
if ((count >= it->second.overflow || count + it->second.value > it->second.overflow ||
|
||||
count + it->second.value <= it->second.value) &&
|
||||
count != 0)
|
||||
return false;
|
||||
|
||||
*firstNum = it->second.value;
|
||||
it->second.value += count;
|
||||
return true;
|
||||
*firstNum = it->second.value;
|
||||
it->second.value += count;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutoincrementManager::resetSequence(uint32_t oid, uint64_t value)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it == sequences.end())
|
||||
return;
|
||||
if (it == sequences.end())
|
||||
return;
|
||||
|
||||
it->second.value = value;
|
||||
it->second.value = value;
|
||||
}
|
||||
|
||||
const uint32_t AutoincrementManager::lockTime = 30;
|
||||
|
||||
void AutoincrementManager::getLock(uint32_t oid)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
ptime stealTime = microsec_clock::local_time() + seconds(lockTime);
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
ptime stealTime = microsec_clock::local_time() + seconds(lockTime);
|
||||
|
||||
bool gotIt = false;
|
||||
bool gotIt = false;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it == sequences.end())
|
||||
throw runtime_error("There is no sequence with that lock");
|
||||
if (it == sequences.end())
|
||||
throw runtime_error("There is no sequence with that lock");
|
||||
|
||||
lk.unlock();
|
||||
lk.unlock();
|
||||
|
||||
while (!gotIt && microsec_clock::local_time() < stealTime)
|
||||
{
|
||||
gotIt = it->second.lock.try_lock();
|
||||
while (!gotIt && microsec_clock::local_time() < stealTime)
|
||||
{
|
||||
gotIt = it->second.lock.try_lock();
|
||||
|
||||
if (!gotIt)
|
||||
usleep(100000);
|
||||
}
|
||||
if (!gotIt)
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
// If !gotIt, take possession
|
||||
// If !gotIt, take possession
|
||||
}
|
||||
|
||||
void AutoincrementManager::releaseLock(uint32_t oid)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it == sequences.end())
|
||||
return; // it's unlocked if the lock doesn't exist...
|
||||
if (it == sequences.end())
|
||||
return; // it's unlocked if the lock doesn't exist...
|
||||
|
||||
lk.unlock();
|
||||
lk.unlock();
|
||||
|
||||
it->second.lock.unlock();
|
||||
it->second.lock.unlock();
|
||||
}
|
||||
|
||||
void AutoincrementManager::deleteSequence(uint32_t oid)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
boost::mutex::scoped_lock lk(lock);
|
||||
map<uint64_t, sequence>::iterator it;
|
||||
|
||||
it = sequences.find(oid);
|
||||
it = sequences.find(oid);
|
||||
|
||||
if (it != sequences.end())
|
||||
sequences.erase(it);
|
||||
if (it != sequences.end())
|
||||
sequences.erase(it);
|
||||
}
|
||||
|
||||
|
||||
} /* namespace BRM */
|
||||
|
Reference in New Issue
Block a user