OmniSciDB  8a228a1076
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 int deviceId, std::string basePath=".", const size_t num_reader_threads=0, const size_t defaultPageSize=2097152)
 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 getChunkMetadataVec (ChunkMetadataVector &chunkMetadataVec) override
 
void getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override
 
void checkpoint () override
 Fsyncs data files, writes out epoch and fsyncs that. More...
 
void checkpoint (const int db_id, const int 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
 
AbstractBufferMgrgetFileMgr (const int db_id, const int tb_id)
 
AbstractBufferMgrgetFileMgr (const ChunkKey &key)
 
std::string getBasePath () const
 
size_t getDefaultPageSize () const
 
void writeFileMgrData (FileMgr *fileMgr=0)
 
int getDBVersion () const
 
bool getDBConvert () const
 
void setDBConvert (bool val)
 
void removeTableRelatedDS (const int db_id, const int tb_id) override
 
void setTableEpoch (const int db_id, const int tb_id, const int start_epoch)
 
size_t getTableEpoch (const int db_id, const int tb_id)
 

Private Member Functions

AbstractBufferMgrfindFileMgr (const int db_id, const int tb_id)
 
void deleteFileMgr (const int db_id, const int tb_id)
 

Private Attributes

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

Detailed Description

Definition at line 47 of file GlobalFileMgr.h.

Constructor & Destructor Documentation

◆ GlobalFileMgr()

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

Constructor.

Definition at line 42 of file GlobalFileMgr.cpp.

References dbConvert_, init(), and mapd_db_version_.

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

◆ alloc()

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

Definition at line 102 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

102  {
103  LOG(FATAL) << "Operation not supported";
104  return nullptr; // satisfy return-type warning
105  }
#define LOG(tag)
Definition: Logger.h:188

◆ checkpoint() [1/2]

void File_Namespace::GlobalFileMgr::checkpoint ( )
override

Fsyncs data files, writes out epoch and fsyncs that.

Definition at line 76 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

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

◆ checkpoint() [2/2]

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

Definition at line 84 of file GlobalFileMgr.cpp.

References getFileMgr().

84  {
85  getFileMgr(db_id, tb_id)->checkpoint();
86 }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)
+ Here is the call graph for this function:

◆ clearSlabs()

void File_Namespace::GlobalFileMgr::clearSlabs ( )
inlineoverride

Definition at line 112 of file GlobalFileMgr.h.

112  { /* noop */
113  }

◆ createBuffer()

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

59  {
60  return getFileMgr(key)->createBuffer(key, pageSize, numBytes);
61  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ deleteBuffer()

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

Deletes the chunk with the specified key.

Definition at line 71 of file GlobalFileMgr.h.

71  {
72  return getFileMgr(key)->deleteBuffer(key, purge);
73  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ deleteBuffersWithPrefix()

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

Definition at line 99 of file GlobalFileMgr.cpp.

References getFileMgr().

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

◆ deleteFileMgr()

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

Definition at line 134 of file GlobalFileMgr.cpp.

References allFileMgrs_, and ownedFileMgrs_.

Referenced by removeTableRelatedDS(), and setTableEpoch().

134  {
135  // NOTE: only call this private function after locking is already in place
136  const auto file_mgr_key = std::make_pair(db_id, tb_id);
137  if (auto it = ownedFileMgrs_.find(file_mgr_key); it != ownedFileMgrs_.end()) {
138  ownedFileMgrs_.erase(it);
139  }
140  if (auto it = allFileMgrs_.find(file_mgr_key); it != allFileMgrs_.end()) {
141  allFileMgrs_.erase(it);
142  }
143 }
std::map< std::pair< int, int >, std::shared_ptr< AbstractBufferMgr > > ownedFileMgrs_
std::map< std::pair< int, int >, AbstractBufferMgr * > allFileMgrs_
+ Here is the caller graph for this function:

◆ fetchBuffer()

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

Definition at line 83 of file GlobalFileMgr.h.

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

◆ findFileMgr()

AbstractBufferMgr * File_Namespace::GlobalFileMgr::findFileMgr ( const int  db_id,
const int  tb_id 
)
private

Definition at line 124 of file GlobalFileMgr.cpp.

References allFileMgrs_.

Referenced by getFileMgr(), and removeTableRelatedDS().

124  {
125  // NOTE: only call this private function after locking is already in place
126  AbstractBufferMgr* fm = nullptr;
127  const auto file_mgr_key = std::make_pair(db_id, tb_id);
128  if (auto it = allFileMgrs_.find(file_mgr_key); it != allFileMgrs_.end()) {
129  fm = it->second;
130  }
131  return fm;
132 }
std::map< std::pair< int, int >, AbstractBufferMgr * > allFileMgrs_
+ Here is the caller graph for this function:

◆ free()

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

Definition at line 107 of file GlobalFileMgr.h.

References logger::FATAL, and LOG.

107 { LOG(FATAL) << "Operation not supported"; }
#define LOG(tag)
Definition: Logger.h:188

◆ getAllocated()

size_t File_Namespace::GlobalFileMgr::getAllocated ( )
inlineoverride

Definition at line 116 of file GlobalFileMgr.h.

116 { return 0; }

◆ getBasePath()

std::string File_Namespace::GlobalFileMgr::getBasePath ( ) const
inline

Definition at line 153 of file GlobalFileMgr.h.

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

153 { return basePath_; }
+ Here is the caller graph for this function:

◆ getBuffer()

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

79  {
80  return getFileMgr(key)->getBuffer(key, numBytes);
81  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ getChunkMetadataVec()

void File_Namespace::GlobalFileMgr::getChunkMetadataVec ( ChunkMetadataVector chunkMetadataVec)
override

Definition at line 110 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

110  {
111  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
112  ChunkMetadataVector chunkMetadataVecForFileMgr;
113  for (auto fileMgrsIt = allFileMgrs_.begin(); fileMgrsIt != allFileMgrs_.end();
114  ++fileMgrsIt) {
115  fileMgrsIt->second->getChunkMetadataVec(chunkMetadataVecForFileMgr);
116  while (!chunkMetadataVecForFileMgr.empty()) {
117  // norair - order of elements is reversed, consider optimising this later if needed
118  chunkMetadataVec.push_back(chunkMetadataVecForFileMgr.back());
119  chunkMetadataVecForFileMgr.pop_back();
120  }
121  }
122 }
std::map< std::pair< int, int >, AbstractBufferMgr * > allFileMgrs_
mapd_shared_lock< mapd_shared_mutex > read_lock
mapd_shared_mutex fileMgrs_mutex_
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata > >> ChunkMetadataVector

◆ getChunkMetadataVecForKeyPrefix()

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

Definition at line 122 of file GlobalFileMgr.h.

123  {
124  return getFileMgr(keyPrefix)->getChunkMetadataVecForKeyPrefix(chunkMetadataVec,
125  keyPrefix);
126  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ getDBConvert()

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

Definition at line 159 of file GlobalFileMgr.h.

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

+ Here is the caller graph for this function:

◆ getDBVersion()

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

Definition at line 158 of file GlobalFileMgr.h.

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

158 { return mapd_db_version_; }
int mapd_db_version_
default page size, used to set FileMgr defaultPageSize_
+ Here is the caller graph for this function:

◆ getDefaultPageSize()

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

Definition at line 154 of file GlobalFileMgr.h.

Referenced by Data_Namespace::DataMgr::convertDB().

+ Here is the caller graph for this function:

◆ getFileMgr() [1/2]

AbstractBufferMgr * File_Namespace::GlobalFileMgr::getFileMgr ( const int  db_id,
const int  tb_id 
)

Definition at line 145 of file GlobalFileMgr.cpp.

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

Referenced by checkpoint(), Data_Namespace::DataMgr::createTopLevelMetadata(), deleteBuffersWithPrefix(), getTableEpoch(), and File_Namespace::FileMgr::init().

145  {
146  { // check if FileMgr already exists for (db_id, tb_id)
147  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
148  AbstractBufferMgr* fm = findFileMgr(db_id, tb_id);
149  if (fm) {
150  return fm;
151  }
152  }
153 
154  { // create new FileMgr for (db_id, tb_id)
155  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
156  AbstractBufferMgr* fm = findFileMgr(db_id, tb_id);
157  if (fm) {
158  return fm; // mgr was added between the read lock and the write lock
159  }
160  const auto file_mgr_key = std::make_pair(db_id, tb_id);
161  const auto foreign_buffer_manager =
163  if (foreign_buffer_manager) {
164  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, foreign_buffer_manager))
165  .second);
166  return foreign_buffer_manager;
167  } else {
168  auto s = std::make_shared<FileMgr>(
169  0, this, file_mgr_key, num_reader_threads_, epoch_, defaultPageSize_);
170  CHECK(ownedFileMgrs_.insert(std::make_pair(file_mgr_key, s)).second);
171  CHECK(allFileMgrs_.insert(std::make_pair(file_mgr_key, s.get())).second);
172  return s.get();
173  }
174  }
175 }
static Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
int epoch_
number of threads used when loading data
std::map< std::pair< int, int >, std::shared_ptr< AbstractBufferMgr > > ownedFileMgrs_
AbstractBufferMgr * findFileMgr(const int db_id, const int tb_id)
std::map< std::pair< int, int >, AbstractBufferMgr * > allFileMgrs_
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:

◆ getFileMgr() [2/2]

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

Definition at line 149 of file GlobalFileMgr.h.

149  {
150  return getFileMgr(key[0], key[1]);
151  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ getInUseSize()

size_t File_Namespace::GlobalFileMgr::getInUseSize ( )
inlineoverride

Definition at line 115 of file GlobalFileMgr.h.

115 { return 0; }

◆ getMaxSize()

size_t File_Namespace::GlobalFileMgr::getMaxSize ( )
inlineoverride

Definition at line 114 of file GlobalFileMgr.h.

114 { return 0; }

◆ getMgrType()

MgrType File_Namespace::GlobalFileMgr::getMgrType ( )
inlineoverride

Definition at line 109 of file GlobalFileMgr.h.

109 { return GLOBAL_FILE_MGR; };

◆ getNumChunks()

size_t File_Namespace::GlobalFileMgr::getNumChunks ( )
override

Definition at line 88 of file GlobalFileMgr.cpp.

References allFileMgrs_, and fileMgrs_mutex_.

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

◆ getNumReaderThreads()

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

139 { return num_reader_threads_; }
size_t num_reader_threads_
The OS file system path containing the files.

◆ getStringMgrType()

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

Definition at line 110 of file GlobalFileMgr.h.

110 { return ToString(GLOBAL_FILE_MGR); }

◆ getTableEpoch()

size_t File_Namespace::GlobalFileMgr::getTableEpoch ( const int  db_id,
const int  tb_id 
)

Definition at line 231 of file GlobalFileMgr.cpp.

References CHECK, and getFileMgr().

Referenced by Data_Namespace::DataMgr::getTableEpoch().

231  {
232  auto fm = dynamic_cast<FileMgr*>(getFileMgr(db_id, tb_id));
233  CHECK(fm);
234  return fm->epoch_;
235 }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void File_Namespace::GlobalFileMgr::init ( )

Definition at line 59 of file GlobalFileMgr.cpp.

References basePath_, logger::FATAL, and LOG.

Referenced by GlobalFileMgr().

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

◆ isAllocationCapped()

bool File_Namespace::GlobalFileMgr::isAllocationCapped ( )
inlineoverride

Definition at line 117 of file GlobalFileMgr.h.

References logger::init().

117 { return false; }
+ Here is the call graph for this function:

◆ isBufferOnDevice()

bool File_Namespace::GlobalFileMgr::isBufferOnDevice ( const ChunkKey key)
inlineoverride

Definition at line 63 of file GlobalFileMgr.h.

63  {
64  return getFileMgr(key)->isBufferOnDevice(key);
65  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ printSlabs()

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

Definition at line 111 of file GlobalFileMgr.h.

111 { return "Not Implemented"; }

◆ putBuffer()

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

97  {
98  return getFileMgr(key)->putBuffer(key, d, numBytes);
99  }
AbstractBufferMgr * getFileMgr(const int db_id, const int tb_id)

◆ removeTableRelatedDS()

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

Definition at line 196 of file GlobalFileMgr.cpp.

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

196  {
197  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
198  auto fm = dynamic_cast<File_Namespace::FileMgr*>(findFileMgr(db_id, tb_id));
199  if (fm) {
200  fm->closeRemovePhysical();
201  } else {
202  // fileMgr has not been initialized so there is no need to
203  // spend the time initializing
204  // initialize just enough to have to rename
205  const auto file_mgr_key = std::make_pair(db_id, tb_id);
206  auto u = std::make_unique<FileMgr>(0, this, file_mgr_key, true);
207  u->closeRemovePhysical();
208  }
209  // remove table related in-memory DS only if directory was removed successfully
210 
211  deleteFileMgr(db_id, tb_id);
212 }
AbstractBufferMgr * findFileMgr(const int db_id, const int tb_id)
mapd_shared_mutex fileMgrs_mutex_
void deleteFileMgr(const int db_id, const int tb_id)
mapd_unique_lock< mapd_shared_mutex > write_lock
+ Here is the call graph for this function:

◆ setDBConvert()

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

Definition at line 160 of file GlobalFileMgr.h.

◆ setTableEpoch()

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

Definition at line 214 of file GlobalFileMgr.cpp.

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

Referenced by Data_Namespace::DataMgr::setTableEpoch().

216  {
217  mapd_unique_lock<mapd_shared_mutex> write_lock(fileMgrs_mutex_);
218  const auto file_mgr_key = std::make_pair(db_id, tb_id);
219  // this is where the real rollback of any data ahead of the currently set epoch is
220  // performed
221  auto u = std::make_unique<FileMgr>(
222  0, this, file_mgr_key, num_reader_threads_, start_epoch, defaultPageSize_);
223  u->setEpoch(start_epoch - 1);
224  // remove the dummy one we built
225  u.reset();
226 
227  // see if one exists currently, and remove it
228  deleteFileMgr(db_id, tb_id);
229 }
size_t num_reader_threads_
The OS file system path containing the files.
mapd_shared_mutex fileMgrs_mutex_
void deleteFileMgr(const int db_id, const int tb_id)
mapd_unique_lock< mapd_shared_mutex > write_lock
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeFileMgrData()

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

Definition at line 177 of file GlobalFileMgr.cpp.

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

178  { // this function is not used, keep it for now for future needs
179  mapd_shared_lock<mapd_shared_mutex> read_lock(fileMgrs_mutex_);
180  for (auto fileMgrIt = allFileMgrs_.begin(); fileMgrIt != allFileMgrs_.end();
181  fileMgrIt++) {
182  FileMgr* fm = dynamic_cast<FileMgr*>(fileMgrIt->second);
183  CHECK(fm);
184  if ((fileMgr != 0) && (fileMgr != fm)) {
185  continue;
186  }
187  for (auto chunkIt = fm->chunkIndex_.begin(); chunkIt != fm->chunkIndex_.end();
188  chunkIt++) {
189  chunkIt->second->write((int8_t*)chunkIt->second, chunkIt->second->size(), 0);
190  // chunkIt->second->write((int8_t*)chunkIt->second, chunkIt->second->size(), 0,
191  // CPU_LEVEL, -1);
192  }
193  }
194 }
std::map< std::pair< int, int >, 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

◆ allFileMgrs_

std::map<std::pair<int, int>, AbstractBufferMgr*> File_Namespace::GlobalFileMgr::allFileMgrs_
private

◆ basePath_

std::string File_Namespace::GlobalFileMgr::basePath_
private

Definition at line 167 of file GlobalFileMgr.h.

Referenced by init().

◆ dbConvert_

bool File_Namespace::GlobalFileMgr::dbConvert_
private

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

Definition at line 182 of file GlobalFileMgr.h.

Referenced by GlobalFileMgr().

◆ defaultPageSize_

size_t File_Namespace::GlobalFileMgr::defaultPageSize_
private

Definition at line 173 of file GlobalFileMgr.h.

Referenced by getFileMgr(), and setTableEpoch().

◆ epoch_

int File_Namespace::GlobalFileMgr::epoch_
private

number of threads used when loading data

Definition at line 169 of file GlobalFileMgr.h.

Referenced by getFileMgr().

◆ fileMgrs_mutex_

mapd_shared_mutex File_Namespace::GlobalFileMgr::fileMgrs_mutex_
private

◆ mapd_db_version_

int File_Namespace::GlobalFileMgr::mapd_db_version_
private

default page size, used to set FileMgr defaultPageSize_

Definition at line 176 of file GlobalFileMgr.h.

Referenced by GlobalFileMgr().

◆ num_reader_threads_

size_t File_Namespace::GlobalFileMgr::num_reader_threads_
private

The OS file system path containing the files.

Definition at line 168 of file GlobalFileMgr.h.

Referenced by getFileMgr(), and setTableEpoch().

◆ ownedFileMgrs_

std::map<std::pair<int, int>, std::shared_ptr<AbstractBufferMgr> > File_Namespace::GlobalFileMgr::ownedFileMgrs_
private

true if conversion should be done between different "mapd_db_version_"

Definition at line 185 of file GlobalFileMgr.h.

Referenced by deleteFileMgr(), and getFileMgr().


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