OmniSciDB  a575cb28ea
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
File_Namespace::GlobalFileMgr Class Reference

#include <GlobalFileMgr.h>

+ Inheritance diagram for File_Namespace::GlobalFileMgr:
+ Collaboration diagram for File_Namespace::GlobalFileMgr:

Public Member Functions

 GlobalFileMgr (const int32_t deviceId, std::string basePath=".", const size_t num_reader_threads=0, const size_t defaultPageSize=DEFAULT_PAGE_SIZE)
 Constructor. More...
 
AbstractBuffercreateBuffer (const ChunkKey &key, size_t pageSize=0, const size_t numBytes=0) override
 Creates a chunk with the specified key and page size. More...
 
bool isBufferOnDevice (const ChunkKey &key) override
 
void deleteBuffer (const ChunkKey &key, const bool purge=true) override
 Deletes the chunk with the specified key. More...
 
void deleteBuffersWithPrefix (const ChunkKey &keyPrefix, const bool purge=true) override
 
AbstractBuffergetBuffer (const ChunkKey &key, const size_t numBytes=0) override
 Returns the a pointer to the chunk with the specified key. More...
 
void fetchBuffer (const ChunkKey &key, AbstractBuffer *destBuffer, const size_t numBytes) override
 
AbstractBufferputBuffer (const ChunkKey &key, AbstractBuffer *d, const size_t numBytes=0) override
 Puts the contents of d into the Chunk with the given key. More...
 
AbstractBufferalloc (const size_t numBytes) override
 
void free (AbstractBuffer *buffer) override
 
MgrType getMgrType () override
 
std::string getStringMgrType () override
 
std::string printSlabs () override
 
void clearSlabs () override
 
size_t getMaxSize () override
 
size_t getInUseSize () override
 
size_t getAllocated () override
 
bool isAllocationCapped () override
 
void init ()
 
void getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override
 
void checkpoint () override
 Fsyncs data files, writes out epoch and fsyncs that. More...
 
void checkpoint (const int32_t db_id, const int32_t tb_id) override
 
size_t getNumReaderThreads ()
 Returns number of threads defined by parameter num-reader-threads which should be used during initial load and consequent read of data. More...
 
size_t getNumChunks () override
 
AbstractBufferMgrfindFileMgr (const int32_t db_id, const int32_t tb_id)
 
void setFileMgrParams (const int32_t db_id, const int32_t tb_id, const FileMgrParams &file_mgr_params)
 
AbstractBufferMgrgetFileMgr (const int32_t db_id, const int32_t tb_id)
 
AbstractBufferMgrgetFileMgr (const ChunkKey &key)
 
std::string getBasePath () const
 
size_t getDefaultPageSize () const
 
void writeFileMgrData (FileMgr *fileMgr=0)
 
int32_t getDBVersion () const
 
bool getDBConvert () const
 
void setDBConvert (bool val)
 
void removeTableRelatedDS (const int32_t db_id, const int32_t tb_id) override
 
void setTableEpoch (const int32_t db_id, const int32_t tb_id, const int32_t start_epoch)
 
size_t getTableEpoch (const int32_t db_id, const int32_t tb_id)
 
StorageStats getStorageStats (const int32_t db_id, const int32_t tb_id)
 
std::shared_ptr< FileMgrgetSharedFileMgr (const int db_id, const int table_id)
 
void setFileMgr (const int db_id, const int table_id, std::shared_ptr< FileMgr > file_mgr)
 
void closeFileMgr (const int32_t db_id, const int32_t tb_id)
 

Private Member Functions

AbstractBufferMgrfindFileMgrUnlocked (const int32_t db_id, const int32_t tb_id)
 
void deleteFileMgr (const int32_t db_id, const int32_t tb_id)
 
bool existsDiffBetweenFileMgrParamsAndFileMgr (FileMgr *file_mgr, const FileMgrParams &file_mgr_params) const
 

Private Attributes

std::string basePath_
 
size_t num_reader_threads_
 The OS file system path containing the files. More...
 
int32_t epoch_
 number of threads used when loading data More...
 
size_t defaultPageSize_
 
int32_t omnisci_db_version_
 default page size, used to set FileMgr defaultPageSize_ More...
 
bool dbConvert_
 
std::map< std::pair< int32_t,
int32_t >, std::shared_ptr
< FileMgr > > 
ownedFileMgrs_
 
std::map< std::pair< int32_t,
int32_t >, AbstractBufferMgr * > 
allFileMgrs_
 
mapd_shared_mutex fileMgrs_mutex_
 

Detailed Description

Definition at line 53 of file GlobalFileMgr.h.

Constructor & Destructor Documentation

File_Namespace::GlobalFileMgr::GlobalFileMgr ( const int32_t  deviceId,
std::string  basePath = ".",
const size_t  num_reader_threads = 0,
const size_t  defaultPageSize = DEFAULT_PAGE_SIZE 
)

Constructor.

Definition at line 41 of file GlobalFileMgr.cpp.

References dbConvert_, init(), and omnisci_db_version_.

45  : AbstractBufferMgr(deviceId)
46  , basePath_(basePath)
47  , num_reader_threads_(num_reader_threads)
48  , epoch_(-1)
49  , // set the default epoch for all tables corresponding to the time of
50  // last checkpoint
51  defaultPageSize_(defaultPageSize) {
53  // DS changes also triggered by individual FileMgr per table project (release 2.1.0)
54  dbConvert_ = false;
55  init();
56 }
int32_t epoch_
number of threads used when loading data
int32_t omnisci_db_version_
default page size, used to set FileMgr defaultPageSize_
size_t num_reader_threads_
The OS file system path containing the files.

+ Here is the call graph for this function:

Member Function Documentation

AbstractBuffer* File_Namespace::GlobalFileMgr::alloc ( const size_t  numBytes)
inlineoverride

Definition at line 108 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

108  {
109  LOG(FATAL) << "Operation not supported";
110  return nullptr; // satisfy return-type warning
111  }
#define LOG(tag)
Definition: Logger.h:188
void File_Namespace::GlobalFileMgr::checkpoint ( )
override

Fsyncs data files, writes out epoch and fsyncs that.

Definition at line 75 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

75  {
76  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
77  for (auto fileMgrsIt = allFileMgrs_.begin(); fileMgrsIt != allFileMgrs_.end();
78  ++fileMgrsIt) {
79  fileMgrsIt->second->checkpoint();
80  }
81 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock
void File_Namespace::GlobalFileMgr::checkpoint ( const int32_t  db_id,
const int32_t  tb_id 
)
override

Definition at line 83 of file GlobalFileMgr.cpp.

References getFileMgr().

83  {
84  getFileMgr(db_id, tb_id)->checkpoint();
85 }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::clearSlabs ( )
inlineoverride

Definition at line 118 of file GlobalFileMgr.h.

118  { /* noop */
119  }
void File_Namespace::GlobalFileMgr::closeFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 131 of file GlobalFileMgr.cpp.

References deleteFileMgr(), and fileMgrs_mutex_.

131  {
132  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
133  deleteFileMgr(db_id, tb_id);
134 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock

+ Here is the call graph for this function:

AbstractBuffer* File_Namespace::GlobalFileMgr::createBuffer ( const ChunkKey key,
size_t  pageSize = 0,
const size_t  numBytes = 0 
)
inlineoverride

Creates a chunk with the specified key and page size.

Definition at line 63 of file GlobalFileMgr.h.

Referenced by foreign_storage::ForeignStorageCache::getChunkBufferForPrecaching().

65  {
66  return getFileMgr(key)->createBuffer(key, pageSize, numBytes);
67  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::deleteBuffer ( const ChunkKey key,
const bool  purge = true 
)
inlineoverride

Deletes the chunk with the specified key.

Definition at line 77 of file GlobalFileMgr.h.

77  {
78  return getFileMgr(key)->deleteBuffer(key, purge);
79  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
void File_Namespace::GlobalFileMgr::deleteBuffersWithPrefix ( const ChunkKey keyPrefix,
const bool  purge = true 
)
override

Definition at line 98 of file GlobalFileMgr.cpp.

References getFileMgr().

98  {
99  /* keyPrefix[0] can be -1 only for gpu or cpu buffers but not for FileMgr.
100  * There is no assert here, as GlobalFileMgr is being called with -1 value as well in
101  * the same loop with other buffers. So the case of -1 will just be ignored, as nothing
102  * needs to be done.
103  */
104  if (keyPrefix[0] != -1) {
105  return getFileMgr(keyPrefix)->deleteBuffersWithPrefix(keyPrefix, purge);
106  }
107 }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::deleteFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)
private

Definition at line 120 of file GlobalFileMgr.cpp.

References allFileMgrs_, and ownedFileMgrs_.

Referenced by closeFileMgr(), removeTableRelatedDS(), setFileMgrParams(), and setTableEpoch().

120  {
121  // NOTE: only call this private function after locking is already in place
122  const auto file_mgr_key = std::make_pair(db_id, tb_id);
123  if (auto it = ownedFileMgrs_.find(file_mgr_key); it != ownedFileMgrs_.end()) {
124  ownedFileMgrs_.erase(it);
125  }
126  if (auto it = allFileMgrs_.find(file_mgr_key); it != allFileMgrs_.end()) {
127  allFileMgrs_.erase(it);
128  }
129 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_

+ Here is the caller graph for this function:

bool File_Namespace::GlobalFileMgr::existsDiffBetweenFileMgrParamsAndFileMgr ( FileMgr file_mgr,
const FileMgrParams file_mgr_params 
) const
private

Definition at line 136 of file GlobalFileMgr.cpp.

References File_Namespace::FileMgrParams::epoch, File_Namespace::FileMgr::lastCheckpointedEpoch(), File_Namespace::FileMgrParams::max_rollback_epochs, and File_Namespace::FileMgr::maxRollbackEpochs().

138  {
139  if (file_mgr_params.epoch != -1 &&
140  file_mgr_params.epoch != file_mgr->lastCheckpointedEpoch()) {
141  return true;
142  }
143  if (file_mgr_params.max_rollback_epochs != -1 &&
144  file_mgr_params.max_rollback_epochs != file_mgr->maxRollbackEpochs()) {
145  return true;
146  }
147  return false;
148 }

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::fetchBuffer ( const ChunkKey key,
AbstractBuffer destBuffer,
const size_t  numBytes 
)
inlineoverride

Definition at line 89 of file GlobalFileMgr.h.

91  {
92  return getFileMgr(key)->fetchBuffer(key, destBuffer, numBytes);
93  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
AbstractBufferMgr* File_Namespace::GlobalFileMgr::findFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)
inline

Definition at line 153 of file GlobalFileMgr.h.

Referenced by getStorageStats(), getTableEpoch(), setFileMgrParams(), and setTableEpoch().

153  {
154  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
155  return findFileMgrUnlocked(db_id, tb_id);
156  }
AbstractBufferMgr * findFileMgrUnlocked(const int32_t db_id, const int32_t tb_id)
mapd_shared_lock< mapd_shared_mutex > read_lock
mapd_shared_mutex fileMgrs_mutex_

+ Here is the caller graph for this function:

AbstractBufferMgr * File_Namespace::GlobalFileMgr::findFileMgrUnlocked ( const int32_t  db_id,
const int32_t  tb_id 
)
private

Definition at line 109 of file GlobalFileMgr.cpp.

References allFileMgrs_.

Referenced by getFileMgr(), and removeTableRelatedDS().

110  {
111  // NOTE: only call this private function after locking is already in place
112  AbstractBufferMgr* fm = nullptr;
113  const auto file_mgr_key = std::make_pair(db_id, tb_id);
114  if (auto it = allFileMgrs_.find(file_mgr_key); it != allFileMgrs_.end()) {
115  fm = it->second;
116  }
117  return fm;
118 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::free ( AbstractBuffer buffer)
inlineoverride

Definition at line 113 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

113 { LOG(FATAL) << "Operation not supported"; }
#define LOG(tag)
Definition: Logger.h:188
size_t File_Namespace::GlobalFileMgr::getAllocated ( )
inlineoverride

Definition at line 122 of file GlobalFileMgr.h.

122 { return 0; }
std::string File_Namespace::GlobalFileMgr::getBasePath ( ) const
inline

Definition at line 165 of file GlobalFileMgr.h.

Referenced by anonymous_namespace{TableArchiver.cpp}::abs_path(), File_Namespace::FileMgr::coreInit(), and File_Namespace::FileMgr::FileMgr().

165 { return basePath_; }

+ Here is the caller graph for this function:

AbstractBuffer* File_Namespace::GlobalFileMgr::getBuffer ( const ChunkKey key,
const size_t  numBytes = 0 
)
inlineoverride

Returns the a pointer to the chunk with the specified key.

Definition at line 85 of file GlobalFileMgr.h.

Referenced by foreign_storage::ForeignStorageCache::getChunkBufferForPrecaching().

85  {
86  return getFileMgr(key)->getBuffer(key, numBytes);
87  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::getChunkMetadataVecForKeyPrefix ( ChunkMetadataVector chunkMetadataVec,
const ChunkKey keyPrefix 
)
inlineoverride

Definition at line 127 of file GlobalFileMgr.h.

128  {
129  return getFileMgr(keyPrefix)->getChunkMetadataVecForKeyPrefix(chunkMetadataVec,
130  keyPrefix);
131  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
bool File_Namespace::GlobalFileMgr::getDBConvert ( ) const
inline

Definition at line 171 of file GlobalFileMgr.h.

Referenced by File_Namespace::FileMgr::getDBConvert().

171 { return dbConvert_; }

+ Here is the caller graph for this function:

int32_t File_Namespace::GlobalFileMgr::getDBVersion ( ) const
inline

Definition at line 170 of file GlobalFileMgr.h.

Referenced by File_Namespace::FileMgr::getDBVersion().

170 { return omnisci_db_version_; }
int32_t omnisci_db_version_
default page size, used to set FileMgr defaultPageSize_

+ Here is the caller graph for this function:

size_t File_Namespace::GlobalFileMgr::getDefaultPageSize ( ) const
inline

Definition at line 166 of file GlobalFileMgr.h.

166 { return defaultPageSize_; }
AbstractBufferMgr * File_Namespace::GlobalFileMgr::getFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 172 of file GlobalFileMgr.cpp.

References allFileMgrs_, CHECK, defaultPageSize_, epoch_, fileMgrs_mutex_, findFileMgrUnlocked(), ForeignStorageInterface::lookupBufferManager(), num_reader_threads_, and ownedFileMgrs_.

Referenced by checkpoint(), deleteBuffersWithPrefix(), foreign_storage::ForeignStorageCache::getCacheDirectoryForTablePrefix(), and File_Namespace::FileMgr::init().

172  {
173  { // check if FileMgr already exists for (db_id, tb_id)
174  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
175  AbstractBufferMgr* fm = findFileMgrUnlocked(db_id, tb_id);
176  if (fm) {
177  return fm;
178  }
179  }
180 
181  { // create new FileMgr for (db_id, tb_id)
182  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
183  AbstractBufferMgr* fm = findFileMgrUnlocked(db_id, tb_id);
184  if (fm) {
185  return fm; // mgr was added between the read lock and the write lock
186  }
187  const auto file_mgr_key = std::make_pair(db_id, tb_id);
188  const auto foreign_buffer_manager =
190  if (foreign_buffer_manager) {
191  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, foreign_buffer_manager))
192  .second);
193  return foreign_buffer_manager;
194  } else {
195  auto s = std::make_shared<FileMgr>(0,
196  this,
197  file_mgr_key,
198  -1 /*DEFAULT_MAX_ROLLBACK_EPOCHS*/,
200  epoch_,
202  CHECK(ownedFileMgrs_.insert(std::make_pair(file_mgr_key, s)).second);
203  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, s.get())).second);
204  return s.get();
205  }
206  }
207 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
int32_t epoch_
number of threads used when loading data
static Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_
AbstractBufferMgr * findFileMgrUnlocked(const int32_t db_id, const int32_t tb_id)
mapd_shared_lock< mapd_shared_mutex > read_lock
size_t num_reader_threads_
The OS file system path containing the files.
#define CHECK(condition)
Definition: Logger.h:197
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AbstractBufferMgr* File_Namespace::GlobalFileMgr::getFileMgr ( const ChunkKey key)
inline

Definition at line 161 of file GlobalFileMgr.h.

161  {
162  return getFileMgr(key[0], key[1]);
163  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
size_t File_Namespace::GlobalFileMgr::getInUseSize ( )
inlineoverride

Definition at line 121 of file GlobalFileMgr.h.

121 { return 0; }
size_t File_Namespace::GlobalFileMgr::getMaxSize ( )
inlineoverride

Definition at line 120 of file GlobalFileMgr.h.

120 { return 0; }
MgrType File_Namespace::GlobalFileMgr::getMgrType ( )
inlineoverride

Definition at line 115 of file GlobalFileMgr.h.

115 { return GLOBAL_FILE_MGR; };
size_t File_Namespace::GlobalFileMgr::getNumChunks ( )
override

Definition at line 87 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

87  {
88  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
89  size_t num_chunks = 0;
90  for (auto fileMgrsIt = allFileMgrs_.begin(); fileMgrsIt != allFileMgrs_.end();
91  ++fileMgrsIt) {
92  num_chunks += fileMgrsIt->second->getNumChunks();
93  }
94 
95  return num_chunks;
96 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
mapd_shared_lock< mapd_shared_mutex > read_lock
mapd_shared_mutex fileMgrs_mutex_
size_t File_Namespace::GlobalFileMgr::getNumReaderThreads ( )
inline

Returns number of threads defined by parameter num-reader-threads which should be used during initial load and consequent read of data.

Definition at line 144 of file GlobalFileMgr.h.

144 { return num_reader_threads_; }
size_t num_reader_threads_
The OS file system path containing the files.
std::shared_ptr< FileMgr > File_Namespace::GlobalFileMgr::getSharedFileMgr ( const int  db_id,
const int  table_id 
)

Definition at line 210 of file GlobalFileMgr.cpp.

References ownedFileMgrs_.

211  {
212  const auto table_key = std::make_pair(db_id, table_id);
213  if (ownedFileMgrs_.find(table_key) == ownedFileMgrs_.end()) {
214  return nullptr;
215  }
216  return ownedFileMgrs_[table_key];
217 }
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_
StorageStats File_Namespace::GlobalFileMgr::getStorageStats ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 297 of file GlobalFileMgr.cpp.

References defaultPageSize_, fileMgrs_mutex_, and findFileMgr().

297  {
298  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
299  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
300  if (opened_fm) {
301  return dynamic_cast<FileMgr*>(opened_fm)->getStorageStats();
302  }
303  // Do not do full init of table just to get storage stats, just check file instead
304  const auto file_mgr_key = std::make_pair(db_id, tb_id);
305  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
306  const auto basic_storage_stats = u->getStorageStats();
307  u.reset();
308  return basic_storage_stats;
309 }
StorageStats getStorageStats(const int32_t db_id, const int32_t tb_id)
mapd_shared_lock< mapd_shared_mutex > read_lock
AbstractBufferMgr * findFileMgr(const int32_t db_id, const int32_t tb_id)
mapd_shared_mutex fileMgrs_mutex_

+ Here is the call graph for this function:

std::string File_Namespace::GlobalFileMgr::getStringMgrType ( )
inlineoverride

Definition at line 116 of file GlobalFileMgr.h.

116 { return ToString(GLOBAL_FILE_MGR); }
size_t File_Namespace::GlobalFileMgr::getTableEpoch ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 281 of file GlobalFileMgr.cpp.

References defaultPageSize_, fileMgrs_mutex_, and findFileMgr().

281  {
282  // UX change was made to this function Oct 2020 to return checkpointed epoch. In turn,
283  // setTableEpoch was changed to set the epoch at the user's input, instead of input - 1
284  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
285  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
286  if (opened_fm) {
287  return dynamic_cast<FileMgr*>(opened_fm)->lastCheckpointedEpoch();
288  }
289  // Do not do full init of table just to get table epoch, just check file instead
290  const auto file_mgr_key = std::make_pair(db_id, tb_id);
291  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
292  const auto epoch = u->lastCheckpointedEpoch();
293  u.reset();
294  return epoch;
295 }
mapd_shared_lock< mapd_shared_mutex > read_lock
AbstractBufferMgr * findFileMgr(const int32_t db_id, const int32_t tb_id)
mapd_shared_mutex fileMgrs_mutex_

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::init ( )

Definition at line 58 of file GlobalFileMgr.cpp.

References basePath_, logger::FATAL, and LOG.

Referenced by GlobalFileMgr().

58  {
59  // check if basePath_ already exists, and if not create one
60  boost::filesystem::path path(basePath_);
61  if (basePath_.size() > 0 && basePath_[basePath_.size() - 1] != '/') {
62  basePath_.push_back('/');
63  }
64  if (boost::filesystem::exists(path)) {
65  if (!boost::filesystem::is_directory(path)) {
66  LOG(FATAL) << "Specified path is not a directory.";
67  }
68  } else { // data directory does not exist
69  if (!boost::filesystem::create_directory(path)) {
70  LOG(FATAL) << "Could not create data directory";
71  }
72  }
73 }
#define LOG(tag)
Definition: Logger.h:188

+ Here is the caller graph for this function:

bool File_Namespace::GlobalFileMgr::isAllocationCapped ( )
inlineoverride

Definition at line 123 of file GlobalFileMgr.h.

123 { return false; }
bool File_Namespace::GlobalFileMgr::isBufferOnDevice ( const ChunkKey key)
inlineoverride

Definition at line 69 of file GlobalFileMgr.h.

69  {
70  return getFileMgr(key)->isBufferOnDevice(key);
71  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
std::string File_Namespace::GlobalFileMgr::printSlabs ( )
inlineoverride

Definition at line 117 of file GlobalFileMgr.h.

117 { return "Not Implemented"; }
AbstractBuffer* File_Namespace::GlobalFileMgr::putBuffer ( const ChunkKey key,
AbstractBuffer d,
const size_t  numBytes = 0 
)
inlineoverride

Puts the contents of d into the Chunk with the given key.

Parameters
key- Unique identifier for a Chunk.
d- An object representing the source data for the Chunk.
Returns
AbstractBuffer*

Definition at line 101 of file GlobalFileMgr.h.

103  {
104  return getFileMgr(key)->putBuffer(key, d, numBytes);
105  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
void File_Namespace::GlobalFileMgr::removeTableRelatedDS ( const int32_t  db_id,
const int32_t  tb_id 
)
override

Definition at line 244 of file GlobalFileMgr.cpp.

References File_Namespace::FileMgr::closeRemovePhysical(), defaultPageSize_, deleteFileMgr(), fileMgrs_mutex_, and findFileMgrUnlocked().

244  {
245  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
246  auto fm = dynamic_cast<File_Namespace::FileMgr*>(findFileMgrUnlocked(db_id, tb_id));
247  if (fm) {
248  fm->closeRemovePhysical();
249  } else {
250  // fileMgr has not been initialized so there is no need to
251  // spend the time initializing
252  // initialize just enough to have to rename
253  const auto file_mgr_key = std::make_pair(db_id, tb_id);
254  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
255  u->closeRemovePhysical();
256  }
257  // remove table related in-memory DS only if directory was removed successfully
258 
259  deleteFileMgr(db_id, tb_id);
260 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
AbstractBufferMgr * findFileMgrUnlocked(const int32_t db_id, const int32_t tb_id)
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::setDBConvert ( bool  val)
inline

Definition at line 172 of file GlobalFileMgr.h.

void File_Namespace::GlobalFileMgr::setFileMgr ( const int  db_id,
const int  table_id,
std::shared_ptr< FileMgr file_mgr 
)

Definition at line 220 of file GlobalFileMgr.cpp.

References allFileMgrs_, and ownedFileMgrs_.

222  {
223  allFileMgrs_[{db_id, table_id}] = file_mgr.get();
224  ownedFileMgrs_[{db_id, table_id}] = file_mgr;
225 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_
void File_Namespace::GlobalFileMgr::setFileMgrParams ( const int32_t  db_id,
const int32_t  tb_id,
const FileMgrParams file_mgr_params 
)

Definition at line 150 of file GlobalFileMgr.cpp.

References allFileMgrs_, CHECK, defaultPageSize_, deleteFileMgr(), File_Namespace::FileMgrParams::epoch, epoch_, fileMgrs_mutex_, findFileMgr(), File_Namespace::FileMgrParams::max_rollback_epochs, num_reader_threads_, and ownedFileMgrs_.

152  {
153  auto fm = dynamic_cast<File_Namespace::FileMgr*>(findFileMgr(db_id, tb_id));
154  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
155  if (fm) {
156  deleteFileMgr(db_id, tb_id);
157  }
158  const auto file_mgr_key = std::make_pair(db_id, tb_id);
159  auto s = std::make_shared<FileMgr>(
160  0,
161  this,
162  file_mgr_key,
163  file_mgr_params.max_rollback_epochs >= 0 ? file_mgr_params.max_rollback_epochs : -1,
165  file_mgr_params.epoch != -1 ? file_mgr_params.epoch : epoch_,
167  CHECK(ownedFileMgrs_.insert(std::make_pair(file_mgr_key, s)).second);
168  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, s.get())).second);
169  return;
170 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
int32_t epoch_
number of threads used when loading data
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_
size_t num_reader_threads_
The OS file system path containing the files.
#define CHECK(condition)
Definition: Logger.h:197
AbstractBufferMgr * findFileMgr(const int32_t db_id, const int32_t tb_id)
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::setTableEpoch ( const int32_t  db_id,
const int32_t  tb_id,
const int32_t  start_epoch 
)

Definition at line 262 of file GlobalFileMgr.cpp.

References defaultPageSize_, deleteFileMgr(), findFileMgr(), and num_reader_threads_.

264  {
265  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
266  if (opened_fm) {
267  // Delete this FileMgr to ensure epoch change occurs in constructor with other
268  // reads/writes locked out
269  deleteFileMgr(db_id, tb_id);
270  }
271  const auto file_mgr_key = std::make_pair(db_id, tb_id);
272  // this is where the real rollback of any data ahead of the currently set epoch is
273  // performed
274  // Will call set_epoch with start_epoch internally
275  auto u = std::make_unique<FileMgr>(
276  0, this, file_mgr_key, -1, num_reader_threads_, start_epoch, defaultPageSize_);
277  // remove the dummy one we built
278  u.reset();
279 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
size_t num_reader_threads_
The OS file system path containing the files.
AbstractBufferMgr * findFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::writeFileMgrData ( FileMgr fileMgr = 0)

Definition at line 227 of file GlobalFileMgr.cpp.

References allFileMgrs_, CHECK, File_Namespace::FileMgr::chunkIndex_, and fileMgrs_mutex_.

228  { // this function is not used, keep it for now for future needs
229  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
230  for (auto fileMgrIt = allFileMgrs_.begin(); fileMgrIt != allFileMgrs_.end();
231  fileMgrIt++) {
232  FileMgr* fm = dynamic_cast<FileMgr*>(fileMgrIt->second);
233  CHECK(fm);
234  if ((fileMgr != 0) && (fileMgr != fm)) {
235  continue;
236  }
237  for (auto chunkIt = fm->chunkIndex_.begin(); chunkIt != fm->chunkIndex_.end();
238  chunkIt++) {
239  chunkIt->second->write((int8_t*)chunkIt->second, chunkIt->second->size(), 0);
240  }
241  }
242 }
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
mapd_shared_lock< mapd_shared_mutex > read_lock
#define CHECK(condition)
Definition: Logger.h:197
mapd_shared_mutex fileMgrs_mutex_

Member Data Documentation

std::map<std::pair<int32_t, int32_t>, AbstractBufferMgr*> File_Namespace::GlobalFileMgr::allFileMgrs_
private
std::string File_Namespace::GlobalFileMgr::basePath_
private

Definition at line 192 of file GlobalFileMgr.h.

Referenced by init().

bool File_Namespace::GlobalFileMgr::dbConvert_
private

DB version for DataMgr DS and corresponding file buffer read/write code

Definition at line 208 of file GlobalFileMgr.h.

Referenced by GlobalFileMgr().

size_t File_Namespace::GlobalFileMgr::defaultPageSize_
private
int32_t File_Namespace::GlobalFileMgr::epoch_
private

number of threads used when loading data

Definition at line 195 of file GlobalFileMgr.h.

Referenced by getFileMgr(), and setFileMgrParams().

mapd_shared_mutex File_Namespace::GlobalFileMgr::fileMgrs_mutex_
private
size_t File_Namespace::GlobalFileMgr::num_reader_threads_
private

The OS file system path containing the files.

Definition at line 193 of file GlobalFileMgr.h.

Referenced by getFileMgr(), setFileMgrParams(), and setTableEpoch().

int32_t File_Namespace::GlobalFileMgr::omnisci_db_version_
private

default page size, used to set FileMgr defaultPageSize_

Definition at line 202 of file GlobalFileMgr.h.

Referenced by GlobalFileMgr().

std::map<std::pair<int32_t, int32_t>, std::shared_ptr<FileMgr> > File_Namespace::GlobalFileMgr::ownedFileMgrs_
private

true if conversion should be done between different "omnisci_db_version_"

Definition at line 211 of file GlobalFileMgr.h.

Referenced by deleteFileMgr(), getFileMgr(), getSharedFileMgr(), setFileMgr(), and setFileMgrParams().


The documentation for this class was generated from the following files: