#pragma once #include #include #include "data/block.h" #include "fs/fs.h" namespace moonshine { using std::string; using std::shared_ptr; struct ICreateSqlPersist { virtual void Save(const string &file, const char *text, size_t cb) { throw ErrNoImpl("ICreateSqlPersist.Save"); } virtual void Load(const string &file, string &text) { throw ErrNoImpl("ICreateSqlPersist.Load"); } }; using CreateSqlPersistPtr = shared_ptr; struct PersistLocation { string path; IFS::FileHandle fd; size_t offset; size_t size; PersistLocation(const string &path_, IFS::FileHandle fd_, size_t offset_, size_t size_) : path(path_), fd(fd_), offset(offset_), size(size_) {} virtual void Close() {} friend ostream & operator <<(ostream &w, const PersistLocation &x) { return w << x.path << " (fd:" << x.fd << ") from " << x.offset << " size " << x.size; } }; using PersistLocationPtr = shared_ptr; struct IColumnsLayout { virtual PersistLocationPtr PrepareColumnPartialWrite(const IColumn &column, const TypeAndName &info, size_t pos_in_block_stream, size_t rows, size_t cb) { throw ErrNoImpl("IColumnsLayout.PrepareColumnPartialWrite"); } virtual void OnWriteDone() {} virtual void OnEncodedPKColumnFound(const IColumn &column, const TypeAndName &info) {} virtual PersistLocationPtr GetReadLocation(const TypeAndName &info, size_t pos_in_block_stream) { throw ErrNoImpl("IColumnsPersist.GetReadLocation"); } virtual size_t GetBlockCount(const SortedSchema &schema) { throw ErrNoImpl("IColumnsPersist.GetBlockCount"); } }; using ColumnsLayoutPtr = shared_ptr; struct ITablesLayout { virtual ColumnsLayoutPtr GetColumnsLayout(const string &table) { throw ErrNoImpl("ITablesLayout.GetColumnsLayout"); } }; using TablesLayoutPtr = shared_ptr; struct IBlockPersist { virtual void WriteBlock(const ColumnsLayoutPtr &layout, const SortedSchema &schema, size_t pos_in_block_stream, const Block &block) { throw ErrNoImpl("IBlockPersist.WriteBlock"); } virtual void ReadBlock(const ColumnsLayoutPtr &layout, const SortedSchema &schema, size_t pos_in_block_stream, Block &block) { throw ErrNoImpl("IBlockPersist.ReadBlock"); } }; using BlockPersistPtr = shared_ptr; }