26 #ifndef DATAMGR_MEMORY_FILE_GLOBAL_FILEMGR_H
27 #define DATAMGR_MEMORY_FILE_GLOBAL_FILEMGR_H
33 #include "../Shared/mapd_shared_mutex.h"
35 #include "../AbstractBuffer.h"
36 #include "../AbstractBufferMgr.h"
39 using namespace Data_Namespace;
41 namespace File_Namespace {
58 std::string basePath =
".",
59 const size_t num_reader_threads = 0,
65 const size_t numBytes = 0)
override {
66 return getFileMgr(key)->createBuffer(key, pageSize, numBytes);
70 return getFileMgr(key)->isBufferOnDevice(key);
78 return getFileMgr(key)->deleteBuffer(key, purge);
81 void deleteBuffersWithPrefix(
const ChunkKey& keyPrefix,
82 const bool purge =
true)
override;
86 return getFileMgr(key)->getBuffer(key, numBytes);
91 const size_t numBytes)
override {
92 return getFileMgr(key)->fetchBuffer(key, destBuffer, numBytes);
103 const size_t numBytes = 0)
override {
104 return getFileMgr(key)->putBuffer(key, d, numBytes);
109 LOG(
FATAL) <<
"Operation not supported";
115 inline MgrType
getMgrType()
override {
return GLOBAL_FILE_MGR; };
117 inline std::string
printSlabs()
override {
return "Not Implemented"; }
128 const ChunkKey& keyPrefix)
override {
129 return getFileMgr(keyPrefix)->getChunkMetadataVecForKeyPrefix(chunkMetadataVec,
137 void checkpoint()
override;
138 void checkpoint(
const int32_t db_id,
const int32_t tb_id)
override;
146 size_t getNumChunks()
override;
149 AbstractBufferMgr* findFileMgrUnlocked(
const int32_t db_id,
const int32_t tb_id);
150 void deleteFileMgr(
const int32_t db_id,
const int32_t tb_id);
153 AbstractBufferMgr*
findFileMgr(
const int32_t db_id,
const int32_t tb_id) {
154 mapd_shared_lock<mapd_shared_mutex>
read_lock(fileMgrs_mutex_);
155 return findFileMgrUnlocked(db_id, tb_id);
157 void setFileMgrParams(
const int32_t db_id,
160 AbstractBufferMgr* getFileMgr(
const int32_t db_id,
const int32_t tb_id);
162 return getFileMgr(key[0], key[1]);
168 void writeFileMgrData(
FileMgr* fileMgr = 0);
174 void removeTableRelatedDS(
const int32_t db_id,
const int32_t tb_id)
override;
175 void setTableEpoch(
const int32_t db_id,
const int32_t tb_id,
const int32_t start_epoch);
176 size_t getTableEpoch(
const int32_t db_id,
const int32_t tb_id);
177 StorageStats getStorageStats(
const int32_t db_id,
const int32_t tb_id);
180 std::shared_ptr<FileMgr> getSharedFileMgr(
const int db_id,
const int table_id);
183 void setFileMgr(
const int db_id,
const int table_id, std::shared_ptr<FileMgr> file_mgr);
184 void closeFileMgr(
const int32_t db_id,
185 const int32_t tb_id);
189 bool existsDiffBetweenFileMgrParamsAndFileMgr(
212 std::map<std::pair<int32_t, int32_t>, AbstractBufferMgr*>
allFileMgrs_;
219 #endif // DATAMGR_MEMORY_FILE_GLOBAL_FILEMGR_H
AbstractBuffer * putBuffer(const ChunkKey &key, AbstractBuffer *d, const size_t numBytes=0) override
Puts the contents of d into the Chunk with the given key.
std::vector< int > ChunkKey
std::string getBasePath() const
std::map< std::pair< int32_t, int32_t >, AbstractBufferMgr * > allFileMgrs_
int32_t epoch_
number of threads used when loading data
bool isBufferOnDevice(const ChunkKey &key) override
AbstractBuffer * createBuffer(const ChunkKey &key, size_t pageSize=0, const size_t numBytes=0) override
Creates a chunk with the specified key and page size.
void setDBConvert(bool val)
bool isAllocationCapped() override
AbstractBuffer * alloc(const size_t numBytes) override
bool getDBConvert() const
AbstractBufferMgr * getFileMgr(const ChunkKey &key)
int32_t getDBVersion() const
std::string getStringMgrType() override
std::map< std::pair< int32_t, int32_t >, std::shared_ptr< FileMgr > > ownedFileMgrs_
#define DEFAULT_PAGE_SIZE
size_t getAllocated() override
void init(LogOptions const &log_opts)
std::shared_timed_mutex mapd_shared_mutex
int32_t omnisci_db_version_
default page size, used to set FileMgr defaultPageSize_
void clearSlabs() override
An AbstractBuffer is a unit of data management for a data manager.
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override
std::string printSlabs() override
void deleteBuffer(const ChunkKey &key, const bool purge=true) override
Deletes the chunk with the specified key.
size_t getDefaultPageSize() const
MgrType getMgrType() override
size_t getMaxSize() override
AbstractBuffer * getBuffer(const ChunkKey &key, const size_t numBytes=0) override
Returns the a pointer to the chunk with the specified key.
void free(AbstractBuffer *buffer) override
mapd_shared_lock< mapd_shared_mutex > read_lock
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)
mapd_shared_mutex fileMgrs_mutex_
void fetchBuffer(const ChunkKey &key, AbstractBuffer *destBuffer, const size_t numBytes) override
size_t getNumReaderThreads()
Returns number of threads defined by parameter num-reader-threads which should be used during initial...
int32_t max_rollback_epochs
size_t getInUseSize() override