OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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::shared_ptr< ForeignStorageInterface > fsi, std::string basePath=".", const size_t num_reader_threads=0, const size_t defaultPageSize=DEFAULT_PAGE_SIZE)
 Constructor. More...
 
 ~GlobalFileMgr () override
 
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
 
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
 
void compactDataFiles (const int32_t db_id, const int32_t tb_id)
 
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)
 

Protected Attributes

std::shared_ptr
< ForeignStorageInterface
fsi_
 

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< TablePair,
std::shared_ptr< FileMgr > > 
ownedFileMgrs_
 
std::map< TablePair,
AbstractBufferMgr * > 
allFileMgrs_
 
std::map< TablePair, int32_t > max_rollback_epochs_per_table_
 
mapd_shared_mutex fileMgrs_mutex_
 

Detailed Description

Definition at line 55 of file GlobalFileMgr.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 42 of file GlobalFileMgr.cpp.

References dbConvert_, init(), and omnisci_db_version_.

47  : AbstractBufferMgr(deviceId)
48  , fsi_(fsi)
49  , basePath_(basePath)
50  , num_reader_threads_(num_reader_threads)
51  , epoch_(-1)
52  , // set the default epoch for all tables corresponding to the time of
53  // last checkpoint
54  defaultPageSize_(defaultPageSize) {
56  // DS changes also triggered by individual FileMgr per table project (release 2.1.0)
57  dbConvert_ = false;
58  init();
59 }
int32_t epoch_
number of threads used when loading data
std::shared_ptr< ForeignStorageInterface > fsi_
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:

File_Namespace::GlobalFileMgr::~GlobalFileMgr ( )
inlineoverride

Definition at line 65 of file GlobalFileMgr.h.

65 {}

Member Function Documentation

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

Definition at line 113 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

113  {
114  LOG(FATAL) << "Operation not supported";
115  return nullptr; // satisfy return-type warning
116  }
#define LOG(tag)
Definition: Logger.h:203
void File_Namespace::GlobalFileMgr::checkpoint ( )
override

Fsyncs data files, writes out epoch and fsyncs that.

Definition at line 78 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

Referenced by File_Namespace::CachingGlobalFileMgr::checkpoint().

78  {
79  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
80  for (auto fileMgrsIt = allFileMgrs_.begin(); fileMgrsIt != allFileMgrs_.end();
81  ++fileMgrsIt) {
82  fileMgrsIt->second->checkpoint();
83  }
84 }
std::map< TablePair, AbstractBufferMgr * > allFileMgrs_
mapd_shared_mutex fileMgrs_mutex_
mapd_unique_lock< mapd_shared_mutex > write_lock

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::checkpoint ( const int32_t  db_id,
const int32_t  tb_id 
)
override

Definition at line 86 of file GlobalFileMgr.cpp.

References getFileMgr().

86  {
87  getFileMgr(db_id, tb_id)->checkpoint();
88 }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the call graph for this function:

void File_Namespace::GlobalFileMgr::closeFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 134 of file GlobalFileMgr.cpp.

References deleteFileMgr(), and fileMgrs_mutex_.

134  {
135  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
136  deleteFileMgr(db_id, tb_id);
137 }
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:

void File_Namespace::GlobalFileMgr::compactDataFiles ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 323 of file GlobalFileMgr.cpp.

References deleteFileMgr(), fileMgrs_mutex_, findFileMgr(), and getFileMgr().

Referenced by TableOptimizer::vacuumDeletedRows().

323  {
324  auto file_mgr = dynamic_cast<File_Namespace::FileMgr*>(findFileMgr(db_id, tb_id));
325  {
326  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
327  if (file_mgr) {
328  file_mgr->compactFiles();
329  deleteFileMgr(db_id, tb_id);
330  }
331  }
332 
333  // Re-initialize file manager
334  getFileMgr(db_id, tb_id);
335 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)
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:

+ Here is the caller 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 68 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::createBuffer().

70  {
71  return getFileMgr(key)->createBuffer(key, pageSize, numBytes);
72  }
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 82 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::deleteBuffer().

82  {
83  return getFileMgr(key)->deleteBuffer(key, purge);
84  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::deleteBuffersWithPrefix ( const ChunkKey keyPrefix,
const bool  purge = true 
)
override

Definition at line 101 of file GlobalFileMgr.cpp.

References getFileMgr().

Referenced by File_Namespace::CachingGlobalFileMgr::deleteBuffersWithPrefix().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 123 of file GlobalFileMgr.cpp.

References allFileMgrs_, and ownedFileMgrs_.

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

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

+ 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 139 of file GlobalFileMgr.cpp.

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

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

+ 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 94 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::checkpoint(), and File_Namespace::CachingGlobalFileMgr::fetchBuffer().

96  {
97  return getFileMgr(key)->fetchBuffer(key, destBuffer, numBytes);
98  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

AbstractBufferMgr* File_Namespace::GlobalFileMgr::findFileMgr ( const int32_t  db_id,
const int32_t  tb_id 
)
inline

Definition at line 158 of file GlobalFileMgr.h.

Referenced by compactDataFiles(), File_Namespace::CachingGlobalFileMgr::fetchBuffer(), getStorageStats(), getTableEpoch(), setFileMgrParams(), and setTableEpoch().

158  {
159  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
160  return findFileMgrUnlocked(db_id, tb_id);
161  }
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 112 of file GlobalFileMgr.cpp.

References allFileMgrs_.

Referenced by getFileMgr(), and removeTableRelatedDS().

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

+ Here is the caller graph for this function:

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

Definition at line 118 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

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

Definition at line 125 of file GlobalFileMgr.h.

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

Definition at line 170 of file GlobalFileMgr.h.

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

170 { 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 90 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::checkpoint().

90  {
91  return getFileMgr(key)->getBuffer(key, numBytes);
92  }
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 130 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::getChunkMetadataVecForKeyPrefix().

131  {
132  return getFileMgr(keyPrefix)->getChunkMetadataVecForKeyPrefix(chunkMetadataVec,
133  keyPrefix);
134  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

bool File_Namespace::GlobalFileMgr::getDBConvert ( ) const
inline

Definition at line 176 of file GlobalFileMgr.h.

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

176 { return dbConvert_; }

+ Here is the caller graph for this function:

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

Definition at line 175 of file GlobalFileMgr.h.

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

175 { 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 171 of file GlobalFileMgr.h.

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

Definition at line 179 of file GlobalFileMgr.cpp.

References allFileMgrs_, CHECK, defaultPageSize_, epoch_, fileMgrs_mutex_, findFileMgrUnlocked(), fsi_, max_rollback_epochs_per_table_, num_reader_threads_, and ownedFileMgrs_.

Referenced by checkpoint(), compactDataFiles(), deleteBuffersWithPrefix(), and File_Namespace::FileMgr::init().

179  {
180  { // check if FileMgr already exists for (db_id, tb_id)
181  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
182  AbstractBufferMgr* fm = findFileMgrUnlocked(db_id, tb_id);
183  if (fm) {
184  return fm;
185  }
186  }
187 
188  { // create new FileMgr for (db_id, tb_id)
189  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
190  AbstractBufferMgr* fm = findFileMgrUnlocked(db_id, tb_id);
191  if (fm) {
192  return fm; // mgr was added between the read lock and the write lock
193  }
194  const auto file_mgr_key = std::make_pair(db_id, tb_id);
195  const auto foreign_buffer_manager = fsi_->lookupBufferManager(db_id, tb_id);
196  if (foreign_buffer_manager) {
197  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, foreign_buffer_manager))
198  .second);
199  return foreign_buffer_manager;
200  } else {
201  int32_t max_rollback_epochs{-1};
202  if (max_rollback_epochs_per_table_.find(file_mgr_key) !=
204  max_rollback_epochs = max_rollback_epochs_per_table_[file_mgr_key];
205  }
206  auto s = std::make_shared<FileMgr>(0,
207  this,
208  file_mgr_key,
209  max_rollback_epochs,
211  epoch_,
213  CHECK(ownedFileMgrs_.insert(std::make_pair(file_mgr_key, s)).second);
214  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, s.get())).second);
215  return s.get();
216  }
217  }
218 }
int32_t epoch_
number of threads used when loading data
std::shared_ptr< ForeignStorageInterface > fsi_
std::map< TablePair, std::shared_ptr< FileMgr > > ownedFileMgrs_
std::map< TablePair, AbstractBufferMgr * > allFileMgrs_
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.
std::map< TablePair, int32_t > max_rollback_epochs_per_table_
#define CHECK(condition)
Definition: Logger.h:209
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 166 of file GlobalFileMgr.h.

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

Definition at line 124 of file GlobalFileMgr.h.

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

Definition at line 123 of file GlobalFileMgr.h.

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

Definition at line 120 of file GlobalFileMgr.h.

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

Definition at line 90 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

90  {
91  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
92  size_t num_chunks = 0;
93  for (auto fileMgrsIt = allFileMgrs_.begin(); fileMgrsIt != allFileMgrs_.end();
94  ++fileMgrsIt) {
95  num_chunks += fileMgrsIt->second->getNumChunks();
96  }
97 
98  return num_chunks;
99 }
std::map< TablePair, 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 147 of file GlobalFileMgr.h.

147 { 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 221 of file GlobalFileMgr.cpp.

References ownedFileMgrs_.

222  {
223  const auto table_key = std::make_pair(db_id, table_id);
224  if (ownedFileMgrs_.find(table_key) == ownedFileMgrs_.end()) {
225  return nullptr;
226  }
227  return ownedFileMgrs_[table_key];
228 }
std::map< TablePair, std::shared_ptr< FileMgr > > ownedFileMgrs_
StorageStats File_Namespace::GlobalFileMgr::getStorageStats ( const int32_t  db_id,
const int32_t  tb_id 
)

Definition at line 309 of file GlobalFileMgr.cpp.

References defaultPageSize_, fileMgrs_mutex_, and findFileMgr().

309  {
310  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
311  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
312  if (opened_fm) {
313  return dynamic_cast<FileMgr*>(opened_fm)->getStorageStats();
314  }
315  // Do not do full init of table just to get storage stats, just check file instead
316  const auto file_mgr_key = std::make_pair(db_id, tb_id);
317  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
318  const auto basic_storage_stats = u->getStorageStats();
319  u.reset();
320  return basic_storage_stats;
321 }
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 121 of file GlobalFileMgr.h.

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

Definition at line 293 of file GlobalFileMgr.cpp.

References defaultPageSize_, fileMgrs_mutex_, and findFileMgr().

293  {
294  // UX change was made to this function Oct 2020 to return checkpointed epoch. In turn,
295  // setTableEpoch was changed to set the epoch at the user's input, instead of input - 1
296  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
297  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
298  if (opened_fm) {
299  return dynamic_cast<FileMgr*>(opened_fm)->lastCheckpointedEpoch();
300  }
301  // Do not do full init of table just to get table epoch, just check file instead
302  const auto file_mgr_key = std::make_pair(db_id, tb_id);
303  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
304  const auto epoch = u->lastCheckpointedEpoch();
305  u.reset();
306  return epoch;
307 }
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 61 of file GlobalFileMgr.cpp.

References basePath_, logger::FATAL, and LOG.

Referenced by GlobalFileMgr().

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

+ Here is the caller graph for this function:

bool File_Namespace::GlobalFileMgr::isAllocationCapped ( )
inlineoverride

Definition at line 126 of file GlobalFileMgr.h.

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

Definition at line 74 of file GlobalFileMgr.h.

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

Definition at line 122 of file GlobalFileMgr.h.

122 { 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 106 of file GlobalFileMgr.h.

Referenced by File_Namespace::CachingGlobalFileMgr::putBuffer().

108  {
109  return getFileMgr(key)->putBuffer(key, d, numBytes);
110  }
AbstractBufferMgr * getFileMgr(const int32_t db_id, const int32_t tb_id)

+ Here is the caller graph for this function:

void File_Namespace::GlobalFileMgr::removeTableRelatedDS ( const int32_t  db_id,
const int32_t  tb_id 
)
override

Definition at line 255 of file GlobalFileMgr.cpp.

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

Referenced by File_Namespace::CachingGlobalFileMgr::removeTableRelatedDS().

255  {
256  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
257  auto fm = dynamic_cast<File_Namespace::FileMgr*>(findFileMgrUnlocked(db_id, tb_id));
258  if (fm) {
259  fm->closeRemovePhysical();
260  } else {
261  // fileMgr has not been initialized so there is no need to
262  // spend the time initializing
263  // initialize just enough to have to rename
264  const auto file_mgr_key = std::make_pair(db_id, tb_id);
265  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, defaultPageSize_, true);
266  u->closeRemovePhysical();
267  }
268  // remove table related in-memory DS only if directory was removed successfully
269 
270  deleteFileMgr(db_id, tb_id);
271  max_rollback_epochs_per_table_.erase({db_id, tb_id});
272 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
AbstractBufferMgr * findFileMgrUnlocked(const int32_t db_id, const int32_t tb_id)
virtual void closeRemovePhysical()
Definition: FileMgr.cpp:550
std::map< TablePair, int32_t > max_rollback_epochs_per_table_
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:

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

Definition at line 177 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 231 of file GlobalFileMgr.cpp.

References allFileMgrs_, and ownedFileMgrs_.

233  {
234  allFileMgrs_[{db_id, table_id}] = file_mgr.get();
235  ownedFileMgrs_[{db_id, table_id}] = file_mgr;
236 }
std::map< TablePair, std::shared_ptr< FileMgr > > ownedFileMgrs_
std::map< TablePair, AbstractBufferMgr * > allFileMgrs_
void File_Namespace::GlobalFileMgr::setFileMgrParams ( const int32_t  db_id,
const int32_t  tb_id,
const FileMgrParams file_mgr_params 
)

Definition at line 153 of file GlobalFileMgr.cpp.

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

155  {
156  auto fm = dynamic_cast<File_Namespace::FileMgr*>(findFileMgr(db_id, tb_id));
157  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
158  if (fm) {
159  deleteFileMgr(db_id, tb_id);
160  }
161  const auto file_mgr_key = std::make_pair(db_id, tb_id);
162  auto max_rollback_epochs =
163  (file_mgr_params.max_rollback_epochs >= 0 ? file_mgr_params.max_rollback_epochs
164  : -1);
165  auto s = std::make_shared<FileMgr>(
166  0,
167  this,
168  file_mgr_key,
169  max_rollback_epochs,
171  file_mgr_params.epoch != -1 ? file_mgr_params.epoch : epoch_,
173  CHECK(ownedFileMgrs_.insert(std::make_pair(file_mgr_key, s)).second);
174  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, s.get())).second);
175  max_rollback_epochs_per_table_[{db_id, tb_id}] = max_rollback_epochs;
176  return;
177 }
void deleteFileMgr(const int32_t db_id, const int32_t tb_id)
int32_t epoch_
number of threads used when loading data
std::map< TablePair, std::shared_ptr< FileMgr > > ownedFileMgrs_
std::map< TablePair, AbstractBufferMgr * > allFileMgrs_
size_t num_reader_threads_
The OS file system path containing the files.
std::map< TablePair, int32_t > max_rollback_epochs_per_table_
#define CHECK(condition)
Definition: Logger.h:209
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 274 of file GlobalFileMgr.cpp.

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

276  {
277  AbstractBufferMgr* opened_fm = findFileMgr(db_id, tb_id);
278  if (opened_fm) {
279  // Delete this FileMgr to ensure epoch change occurs in constructor with other
280  // reads/writes locked out
281  deleteFileMgr(db_id, tb_id);
282  }
283  const auto file_mgr_key = std::make_pair(db_id, tb_id);
284  // this is where the real rollback of any data ahead of the currently set epoch is
285  // performed
286  // Will call set_epoch with start_epoch internally
287  auto u = std::make_unique<FileMgr>(
288  0, this, file_mgr_key, -1, num_reader_threads_, start_epoch, defaultPageSize_);
289  // remove the dummy one we built
290  u.reset();
291 }
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 238 of file GlobalFileMgr.cpp.

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

239  { // this function is not used, keep it for now for future needs
240  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
241  for (auto fileMgrIt = allFileMgrs_.begin(); fileMgrIt != allFileMgrs_.end();
242  fileMgrIt++) {
243  FileMgr* fm = dynamic_cast<FileMgr*>(fileMgrIt->second);
244  CHECK(fm);
245  if ((fileMgr != 0) && (fileMgr != fm)) {
246  continue;
247  }
248  for (auto chunkIt = fm->chunkIndex_.begin(); chunkIt != fm->chunkIndex_.end();
249  chunkIt++) {
250  chunkIt->second->write((int8_t*)chunkIt->second, chunkIt->second->size(), 0);
251  }
252  }
253 }
std::map< TablePair, AbstractBufferMgr * > allFileMgrs_
mapd_shared_lock< mapd_shared_mutex > read_lock
#define CHECK(condition)
Definition: Logger.h:209
mapd_shared_mutex fileMgrs_mutex_

Member Data Documentation

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

Definition at line 199 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 215 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 202 of file GlobalFileMgr.h.

Referenced by getFileMgr(), and setFileMgrParams().

std::shared_ptr<ForeignStorageInterface> File_Namespace::GlobalFileMgr::fsi_
protected
std::map<TablePair, int32_t> File_Namespace::GlobalFileMgr::max_rollback_epochs_per_table_
private

Definition at line 220 of file GlobalFileMgr.h.

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

size_t File_Namespace::GlobalFileMgr::num_reader_threads_
private

The OS file system path containing the files.

Definition at line 200 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 209 of file GlobalFileMgr.h.

Referenced by GlobalFileMgr().

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

true if conversion should be done between different "omnisci_db_version_"

Definition at line 218 of file GlobalFileMgr.h.

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


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