1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -35,7 +35,7 @@
using namespace std;
namespace
{
boost::mutex fac_guard;
boost::mutex fac_guard;
}
namespace idbdatafile
@ -45,74 +45,77 @@ IDBFactory::FactoryMap IDBFactory::s_plugins;
bool IDBFactory::installDefaultPlugins()
{
// protect these methods since we are changing our static data structure
boost::mutex::scoped_lock lock( fac_guard );
// protect these methods since we are changing our static data structure
boost::mutex::scoped_lock lock( fac_guard );
s_plugins[IDBDataFile::BUFFERED] = FileFactoryEnt(IDBDataFile::BUFFERED, "buffered", new BufferedFileFactory(), new PosixFileSystem());
s_plugins[IDBDataFile::UNBUFFERED] = FileFactoryEnt(IDBDataFile::UNBUFFERED, "unbuffered", new UnbufferedFileFactory(), new PosixFileSystem());
s_plugins[IDBDataFile::BUFFERED] = FileFactoryEnt(IDBDataFile::BUFFERED, "buffered", new BufferedFileFactory(), new PosixFileSystem());
s_plugins[IDBDataFile::UNBUFFERED] = FileFactoryEnt(IDBDataFile::UNBUFFERED, "unbuffered", new UnbufferedFileFactory(), new PosixFileSystem());
return false;
return false;
}
bool IDBFactory::installPlugin(const std::string& plugin)
{
#ifdef _MSC_VER
ostringstream oss;
ostringstream oss;
oss << "InfiniDB for Windows does not support plugins: plugin = " << plugin;
throw std::runtime_error(oss.str());
throw std::runtime_error(oss.str());
#else
// protect these methods since we are changing our static data structure
boost::mutex::scoped_lock lock( fac_guard );
// protect these methods since we are changing our static data structure
boost::mutex::scoped_lock lock( fac_guard );
void* handle = dlopen(plugin.c_str(), RTLD_LAZY);
if( handle == NULL )
{
std::ostringstream oss;
oss << "IDBFactory::installPlugin: dlopen for " << plugin << " failed: " << dlerror();
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_ERROR);
return false;
}
void* handle = dlopen(plugin.c_str(), RTLD_LAZY);
void* functor = dlsym(handle, "plugin_instance");
if( functor == NULL )
{
if ( handle == NULL )
{
std::ostringstream oss;
oss << "IDBFactory::installPlugin: dlopen for " << plugin << " failed: " << dlerror();
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_ERROR);
return false;
}
void* functor = dlsym(handle, "plugin_instance");
if ( functor == NULL )
{
std::ostringstream oss;
oss << "IDBFactory::installPlugin: dlsym for plugin_instance() failed. plugin " << plugin << dlerror();
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_ERROR);
return false;
}
FileFactoryEnt ent = (*(FileFactoryEntryFunc)functor)();
s_plugins[ent.type] = ent;
return false;
}
FileFactoryEnt ent = (*(FileFactoryEntryFunc)functor)();
s_plugins[ent.type] = ent;
std::ostringstream oss;
oss << "IDBFactory::installPlugin: installed filesystem plugin " << plugin;
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_DEBUG);
return true;
return true;
#endif
}
IDBDataFile* IDBFactory::open(IDBDataFile::Types type, const char* fname, const char* mode, unsigned opts, unsigned colWidth)
{
if( s_plugins.find(type) == s_plugins.end() )
{
ostringstream oss;
oss << "Cannot find factory plugin type " << (int) type << " to open file: " << fname;
throw std::runtime_error(oss.str());
}
if ( s_plugins.find(type) == s_plugins.end() )
{
ostringstream oss;
oss << "Cannot find factory plugin type " << (int) type << " to open file: " << fname;
throw std::runtime_error(oss.str());
}
return s_plugins[type].factory->open(fname, mode, opts, colWidth);
return s_plugins[type].factory->open(fname, mode, opts, colWidth);
}
IDBFileSystem& IDBFactory::getFs(IDBDataFile::Types type)
{
if( s_plugins.find(type) == s_plugins.end() )
{
ostringstream oss;
oss << "Cannot find filesystem for plugin type " << (int) type;
throw std::runtime_error(oss.str());
}
if ( s_plugins.find(type) == s_plugins.end() )
{
ostringstream oss;
oss << "Cannot find filesystem for plugin type " << (int) type;
throw std::runtime_error(oss.str());
}
return *(s_plugins[type].filesystem);
return *(s_plugins[type].filesystem);
}
}