You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
clang format apply
This commit is contained in:
@ -42,94 +42,97 @@ boost::mutex fac_guard;
|
||||
|
||||
namespace idbdatafile
|
||||
{
|
||||
|
||||
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());
|
||||
|
||||
// TODO: use the installPlugin fcn below instead of declaring this statically, then remove the dependency
|
||||
// IDBDatafile -> cloudio
|
||||
//s_plugins[IDBDataFile::CLOUD] = FileFactoryEnt(IDBDataFile::CLOUD, "cloud", new SMFileFactory(), new SMFileSystem());
|
||||
|
||||
return false;
|
||||
s_plugins[IDBDataFile::BUFFERED] =
|
||||
FileFactoryEnt(IDBDataFile::BUFFERED, "buffered", new BufferedFileFactory(), new PosixFileSystem());
|
||||
s_plugins[IDBDataFile::UNBUFFERED] = FileFactoryEnt(IDBDataFile::UNBUFFERED, "unbuffered",
|
||||
new UnbufferedFileFactory(), new PosixFileSystem());
|
||||
|
||||
// TODO: use the installPlugin fcn below instead of declaring this statically, then remove the dependency
|
||||
// IDBDatafile -> cloudio
|
||||
// s_plugins[IDBDataFile::CLOUD] = FileFactoryEnt(IDBDataFile::CLOUD, "cloud", new SMFileFactory(), new
|
||||
// SMFileSystem());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IDBFactory::installPlugin(const std::string& plugin)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
ostringstream oss;
|
||||
oss << "InfiniDB for Windows does not support plugins: plugin = " << plugin;
|
||||
throw std::runtime_error(oss.str());
|
||||
ostringstream oss;
|
||||
oss << "InfiniDB for Windows does not support plugins: plugin = " << plugin;
|
||||
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* 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;
|
||||
void* handle = dlopen(plugin.c_str(), RTLD_LAZY);
|
||||
|
||||
if (handle == NULL)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "IDBFactory::installPlugin: installed filesystem plugin " << plugin;
|
||||
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_DEBUG);
|
||||
return true;
|
||||
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;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "IDBFactory::installPlugin: installed filesystem plugin " << plugin;
|
||||
IDBLogger::syslog(oss.str(), logging::LOG_TYPE_DEBUG);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
vector<IDBDataFile::Types> IDBFactory::listPlugins()
|
||||
{
|
||||
vector<IDBDataFile::Types> ret;
|
||||
for (FactoryMap::iterator it = s_plugins.begin(); it != s_plugins.end(); ++it)
|
||||
ret.push_back(it->first);
|
||||
return ret;
|
||||
vector<IDBDataFile::Types> ret;
|
||||
for (FactoryMap::iterator it = s_plugins.begin(); it != s_plugins.end(); ++it)
|
||||
ret.push_back(it->first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IDBDataFile* IDBFactory::open(IDBDataFile::Types type, const char* fname, const char* mode, unsigned opts, unsigned colWidth)
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace idbdatafile
|
||||
|
Reference in New Issue
Block a user