Documentation ¶
Index ¶
- Constants
- func Validate(fs afero.Fs) error
- type DBFS
- func (dbfs *DBFS) Close() error
- func (dbfs *DBFS) CreateTable(name string) (Table, error)
- func (dbfs *DBFS) HasTable(name string) (bool, error)
- func (dbfs *DBFS) LoadTablesInfo() (TablesInfo, error)
- func (dbfs *DBFS) StoreSchema(table string, sf *SchemaFile) error
- func (dbfs *DBFS) StoreTablesInfo(info TablesInfo) error
- func (dbfs *DBFS) Table(name string) (Table, error)
- func (dbfs *DBFS) TableCount() (int, error)
- type Error
- type PagedFile
- func (pf *PagedFile) AllocateNewPage() (*page.Page, error)
- func (pf *PagedFile) AllocatePageWithID(id page.ID) (*page.Page, error)
- func (pf *PagedFile) Close() error
- func (pf *PagedFile) FindUnusedPageID() (page.ID, error)
- func (pf *PagedFile) LoadPage(id page.ID) (*page.Page, error)
- func (pf *PagedFile) PageCount() int
- func (pf *PagedFile) Pages() []page.ID
- func (pf *PagedFile) StorePage(p *page.Page) error
- type SchemaFile
- type Table
- type TablesInfo
Constants ¶
const ( TablesDirectory = "tables" TablesInfoFile = "tables.info" TableDataFile = "data" TableSchemaFile = "schema" )
Used filenames.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate checks a file system for a valid database file structure. This check is performed in the root directory of the given file system. If an error occurs, it will be returned.
Note: a file structure is also considered invalid, if the contents of certain files do not match. Calling this method will not check every file for its contents, especially no data files. However, it will check for integrity of the tables.info file any will check any indices, if present.
Types ¶
type DBFS ¶
type DBFS struct {
// contains filtered or unexported fields
}
DBFS represents the structure of a single DataBase-FileSystem. It provides easy access to all folders and files within the root directory, with wrappers for easily modifying the files.
func (*DBFS) CreateTable ¶
CreateTable creates empty table files for a table with the given name. This will return an error if a table with the given name already exists. Calling this method will also create an entry in the tables info file.
func (*DBFS) HasTable ¶
HasTable determines whether or not a table with the given name exists in this database.
func (*DBFS) LoadTablesInfo ¶
func (dbfs *DBFS) LoadTablesInfo() (TablesInfo, error)
LoadTablesInfo loads the content of the tables.info file as structured content. The returned TablesInfo is a value, and must be stored using StoreTablesInfo to persist any changes.
func (*DBFS) StoreSchema ¶
func (dbfs *DBFS) StoreSchema(table string, sf *SchemaFile) error
StoreSchema will store the given schema information in the schema file of the table with the given name. If the table doesn't exist, an error is returned. The current content of the schema file will be overwritten.
func (*DBFS) StoreTablesInfo ¶
func (dbfs *DBFS) StoreTablesInfo(info TablesInfo) error
StoreTablesInfo stores the given TablesInfo in the tables.info file. This completely overwrites the existing content in the file.
func (*DBFS) Table ¶
Table returns a Table object representing the files and directories for the table with the given name, or an error if the table does not exist. Call HasTable to see whether a table with a given name exists.
func (*DBFS) TableCount ¶
TableCount returns the amount of tables that currently exist in this database.
type Error ¶
type Error string
Error is a sentinel error type.
const ( // ErrPageNotExist indicates that the requested page does not exist. ErrPageNotExist Error = "page doesn't exist" )
type PagedFile ¶
type PagedFile struct {
// contains filtered or unexported fields
}
PagedFile provides access to pages within a file that is made up of pages. Everything about this file is expensive, and pages and objects of this type should probably be cached whenever possible.
func (*PagedFile) AllocateNewPage ¶
AllocateNewPage will create a new page in this file and immediately write it to disk. The ID of the new page will be determined by calling FindUnusedPageID.
func (*PagedFile) AllocatePageWithID ¶
AllocatePageWithID will allocate a new page, but instead of finding an available page ID, this will use the given ID. If a page with that ID already exists, an error is returned. Otherwise, the page is added to the PagedFile and a full page is allocated on disk.
func (*PagedFile) FindUnusedPageID ¶
FindUnusedPageID finds an unused page ID in this paged file. You can use this together with AllocatePageWithID, or use AllocateNewPage in the first place.
func (*PagedFile) LoadPage ¶
LoadPage loads a page with the given ID from the disk. If no such page exists, an error is returned. The returned page is an in-memory copy of the page on disk, and modifying will not change any data on the disk. To modify disk data, modify the page and call StorePage with the modified page.
type SchemaFile ¶
SchemaFile provides access to the schema of a table. After modification, call Store to write the modified schema back to disk.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a wrapper around the table directory of a specific table.
func (Table) DataFile ¶
DataFile returns the data file of the table that this object represents. Calling this will load a new PagedFile, which is expensive. Cache the returned page if possible.
func (Table) SchemaFile ¶
func (t Table) SchemaFile() (*SchemaFile, error)
SchemaFile returns a new schema file which contains information about the table schema.
type TablesInfo ¶
TablesInfo is a structured representation of the contents in the tables.info file.