24 #include <unordered_map>
29 const std::vector<int8_t>
buff;
36 virtual void append(
const std::vector<ForeignStorageColumnBuffer>& column_buffers) = 0;
40 const size_t num_bytes) = 0;
43 const size_t num_bytes) {
47 const std::string&
type,
49 std::list<ColumnDescriptor>& ) {}
51 std::pair<int, int> table_key,
52 const std::string&
type,
54 const std::list<ColumnDescriptor>& cols,
55 Data_Namespace::AbstractBufferMgr* mgr) = 0;
56 virtual void dropTable(
const int db_id,
const int table_id) = 0;
57 virtual std::string
getType()
const = 0;
65 void read(int8_t*
const dst,
66 const size_t numBytes,
67 const size_t offset = 0,
69 const int dstDeviceId = -1)
override;
72 const size_t numBytes,
74 const int deviceId = -1)
override;
83 const size_t numBytes,
84 const size_t offset = 0,
86 const int srcDeviceId = -1)
override {
129 const size_t pageSize = 0,
130 const size_t initialSize = 0)
override;
133 const size_t numBytes = 0)
override;
137 const size_t numBytes = 0)
override;
140 const ChunkKey& keyPrefix)
override;
154 const bool purge =
true)
override {
160 const size_t numBytes = 0)
override {
216 std::map<ChunkKey, std::unique_ptr<ForeignStorageBuffer>>
chunk_index_;
236 std::unique_ptr<PersistentForeignStorageInterface> persistent_foreign_storage);
241 std::list<ColumnDescriptor>& cols);
245 const std::list<ColumnDescriptor>& cols);
248 std::unordered_map<std::string, std::unique_ptr<PersistentForeignStorageInterface>>
252 std::map<std::pair<int, int>, std::unique_ptr<ForeignStorageBufferMgr>>
managers_map_;
void reserve(size_t numBytes) override
PersistentForeignStorageInterface * persistent_foreign_storage_
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix) override
void deleteBuffer(const ChunkKey &key, const bool purge=true) override
std::vector< int > ChunkKey
virtual ~PersistentForeignStorageInterface()
void checkpoint(const int db_id, const int tb_id) override
std::unordered_map< std::string, std::unique_ptr< PersistentForeignStorageInterface > > persistent_storage_interfaces_
class for a per-database catalog. also includes metadata for the current database and the current use...
virtual void registerTable(Catalog_Namespace::Catalog *catalog, std::pair< int, int > table_key, const std::string &type, const TableDescriptor &td, const std::list< ColumnDescriptor > &cols, Data_Namespace::AbstractBufferMgr *mgr)=0
void checkpoint() override
Data_Namespace::AbstractBufferMgr * lookupBufferManager(const int db_id, const int table_id)
void append(int8_t *src, const size_t numBytes, const Data_Namespace::MemoryLevel srcBufferType=Data_Namespace::CPU_LEVEL, const int deviceId=-1) override
ForeignStorageInterface & operator=(const ForeignStorageInterface &other)=delete
size_t reservedSize() const override
const ChunkKey chunk_key_
std::string getStringMgrType() override
std::vector< int8_t > moveBuffer()
size_t pageSize() const override
void write(int8_t *src, const size_t numBytes, const size_t offset=0, const Data_Namespace::MemoryLevel srcBufferType=Data_Namespace::CPU_LEVEL, const int srcDeviceId=-1) override
bool isAllocationCapped() override
void free(Data_Namespace::AbstractBuffer *buffer) override
MgrType getMgrType() override
void fetchBuffer(const ChunkKey &key, Data_Namespace::AbstractBuffer *destBuffer, const size_t numBytes=0) override
int8_t * getMemoryPtr() override
std::shared_lock< T > shared_lock
void registerPersistentStorageInterface(std::unique_ptr< PersistentForeignStorageInterface > persistent_foreign_storage)
Data_Namespace::AbstractBuffer * putBuffer(const ChunkKey &key, Data_Namespace::AbstractBuffer *srcBuffer, const size_t numBytes=0) override
bool isBufferOnDevice(const ChunkKey &key) override
ForeignStorageBufferMgr(const int db_id, const int table_id, PersistentForeignStorageInterface *persistent_foreign_storage)
virtual void prepareTable(const int, const std::string &type, TableDescriptor &, std::list< ColumnDescriptor > &)
size_t getAllocated() override
size_t getNumChunks() override
virtual void append(const std::vector< ForeignStorageColumnBuffer > &column_buffers)=0
ForeignStorageBuffer(const ChunkKey &chunk_key, PersistentForeignStorageInterface *persistent_foreign_storage)
An AbstractBuffer is a unit of data management for a data manager.
void registerTable(Catalog_Namespace::Catalog *catalog, const TableDescriptor &td, const std::list< ColumnDescriptor > &cols)
ids are created
std::mutex persistent_storage_interfaces_mutex_
std::map< ChunkKey, std::unique_ptr< ForeignStorageBuffer > > chunk_index_
ForeignStorageInterface()
std::vector< int8_t > buff_
virtual void dropTable(const int db_id, const int table_id)=0
Data_Namespace::AbstractBuffer * getBuffer(const ChunkKey &key, const size_t numBytes=0) override
virtual int8_t * tryZeroCopy(const ChunkKey &chunk_key, const SQLTypeInfo &sql_type, const size_t num_bytes)
const SQLTypeInfo sql_type
Data_Namespace::AbstractBuffer * alloc(const size_t numBytes=0) override
size_t getMaxSize() override
std::map< std::pair< int, int >, PersistentForeignStorageInterface * > table_persistent_storage_interface_map_
heavyai::shared_mutex chunk_index_mutex_
void dropBufferManager(const int db_id, const int table_id)
~ForeignStorageInterface()
Data_Namespace::MemoryLevel getType() const override
std::map< std::pair< int, int >, std::unique_ptr< ForeignStorageBufferMgr > > managers_map_
size_t getInUseSize() override
std::string printSlabs() override
PersistentForeignStorageInterface * persistent_foreign_storage_
std::shared_timed_mutex shared_mutex
void deleteBuffersWithPrefix(const ChunkKey &keyPrefix, const bool purge=true) override
void read(int8_t *const dst, const size_t numBytes, const size_t offset=0, const Data_Namespace::MemoryLevel dstBufferType=Data_Namespace::CPU_LEVEL, const int dstDeviceId=-1) override
size_t pageCount() const override
virtual std::string getType() const =0
const std::vector< int8_t > buff
virtual void read(const ChunkKey &chunk_key, const SQLTypeInfo &sql_type, int8_t *dest, const size_t num_bytes)=0
int8_t * tryZeroCopy(const size_t numBytes)
void removeTableRelatedDS(const int db_id, const int table_id) override
void prepareTable(const int db_id, TableDescriptor &td, std::list< ColumnDescriptor > &cols)
prepare table options and modify columns
Data_Namespace::AbstractBuffer * createBuffer(const ChunkKey &key, const size_t pageSize=0, const size_t initialSize=0) override