mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
EM scaleability project has two parts: phase1 and phase2. This is phase1 that brings EM index to speed up(from O(n) down to the speed of boost::unordered_map) EM lookups looking for <dbroot, oid, partition> tuple to turn it into LBID, e.g. most bulk insertion meta info operations. The basis is boost::shared_managed_object where EMIndex is stored. Whilst it is not debug-friendly it allows to put a nested structs into shmem. EMIndex has 3 tiers. Top down description: vector of dbroots, map of oids to partition vectors, partition vectors that have EM indices. Separate EM methods now queries index before they do EM run. EMIndex has a separate shmem file with the fixed id MCS-shm-00060001.
119 lines
2.7 KiB
C++
119 lines
2.7 KiB
C++
/* Copyright (C) 2014 InfiniDB, Inc.
|
|
Copyright (C) 2016-2022 MariaDB Corporation
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; version 2 of
|
|
the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
/* Takes two params,
|
|
* first, which lock use
|
|
* second, which side to use (read or write)
|
|
* third, lock or unlock it
|
|
*/
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <stdlib.h>
|
|
#include <rwlock.h>
|
|
|
|
using namespace std;
|
|
using namespace rwlock;
|
|
|
|
char* name;
|
|
|
|
void usage()
|
|
{
|
|
std::cout << "Usage " << name << " which_lock_to_use which_side_to_use lock_or_unlock" << std::endl;
|
|
size_t lockId = 0;
|
|
for (auto& lockName : RWLockNames)
|
|
{
|
|
std::cout << " " << lockId++ << "=" << lockName << " ";
|
|
}
|
|
std::cout << std::endl
|
|
<< " which_side_to_use: r|w (read or write)" << std::endl
|
|
<< " lock_or_unlock: l|u (lock or unlock)" << std::endl;
|
|
exit(1);
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
uint32_t which_lock; // 1-5
|
|
uint32_t which_side; // 0 or 1
|
|
uint32_t lock_unlock; // 0 or 1
|
|
RWLock* rwlock;
|
|
|
|
name = argv[0];
|
|
|
|
if (argc != 4)
|
|
usage();
|
|
|
|
if (strlen(argv[1]) != 1 || strlen(argv[2]) != 1 || strlen(argv[3]) != 1)
|
|
usage();
|
|
|
|
try
|
|
{
|
|
which_lock = std::stoi(argv[1]);
|
|
}
|
|
catch (std::exception const& e)
|
|
{
|
|
std::cerr << "Cannot convert the lock id: " << e.what() << std::endl;
|
|
usage();
|
|
}
|
|
|
|
if (which_lock >= RWLockNames.size())
|
|
usage();
|
|
|
|
size_t minLockId = (which_lock > 0) ? which_lock : 1;
|
|
size_t maxLockId = (which_lock > 0) ? which_lock : RWLockNames.size() - 1;
|
|
|
|
if (argv[2][0] == 'r')
|
|
which_side = 0;
|
|
else if (argv[2][0] == 'w')
|
|
which_side = 1;
|
|
else
|
|
usage();
|
|
|
|
if (argv[3][0] == 'l')
|
|
lock_unlock = 0;
|
|
else if (argv[3][0] == 'u')
|
|
lock_unlock = 1;
|
|
else
|
|
usage();
|
|
|
|
for (size_t i = minLockId; i <= maxLockId; ++i)
|
|
{
|
|
rwlock = new RWLock(0x10000 * which_lock);
|
|
|
|
if (which_side == 0)
|
|
{
|
|
if (lock_unlock == 0)
|
|
rwlock->read_lock();
|
|
else
|
|
rwlock->read_unlock();
|
|
}
|
|
else if (lock_unlock == 0)
|
|
{
|
|
rwlock->write_lock();
|
|
}
|
|
else
|
|
{
|
|
rwlock->write_unlock();
|
|
}
|
|
|
|
delete rwlock;
|
|
}
|
|
|
|
return 0;
|
|
}
|