Documentation
¶
Index ¶
- type DiskManager
- type DiskManagerImpl
- func (d *DiskManagerImpl) AllocatePage() types.PageID
- func (d *DiskManagerImpl) DeallocatePage(pageID types.PageID)
- func (d *DiskManagerImpl) GCLogFile() error
- func (d *DiskManagerImpl) GetLogFileSize() int64
- func (d *DiskManagerImpl) GetNumWrites() uint64
- func (d *DiskManagerImpl) ReadLog(log_data []byte, offset int32, retReadBytes *uint32) bool
- func (d *DiskManagerImpl) ReadPage(pageID types.PageID, pageData []byte) error
- func (d *DiskManagerImpl) RemoveDBFile()
- func (d *DiskManagerImpl) RemoveLogFile()
- func (d *DiskManagerImpl) ShutDown()
- func (d *DiskManagerImpl) Size() int64
- func (d *DiskManagerImpl) WriteLog(log_data []byte)
- func (d *DiskManagerImpl) WritePage(pageId types.PageID, pageData []byte) error
- type DiskManagerTest
- type VirtualDiskManagerImpl
- func (d *VirtualDiskManagerImpl) AllocatePage() types.PageID
- func (d *VirtualDiskManagerImpl) DeallocatePage(pageID types.PageID)
- func (d *VirtualDiskManagerImpl) GCLogFile() error
- func (d *VirtualDiskManagerImpl) GetLogFileSize() int64
- func (d *VirtualDiskManagerImpl) GetNumWrites() uint64
- func (d *VirtualDiskManagerImpl) ReadLog(log_data []byte, offset int32, retReadBytes *uint32) bool
- func (d *VirtualDiskManagerImpl) ReadPage(pageID types.PageID, pageData []byte) error
- func (d *VirtualDiskManagerImpl) RemoveDBFile()
- func (d *VirtualDiskManagerImpl) RemoveLogFile()
- func (d *VirtualDiskManagerImpl) ShutDown()
- func (d *VirtualDiskManagerImpl) Size() int64
- func (d *VirtualDiskManagerImpl) WriteLog(log_data []byte)
- func (d *VirtualDiskManagerImpl) WritePage(pageId types.PageID, pageData []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskManager ¶
type DiskManager interface {
ReadPage(types.PageID, []byte) error
WritePage(types.PageID, []byte) error
AllocatePage() types.PageID
DeallocatePage(types.PageID)
GetNumWrites() uint64
ShutDown()
Size() int64
RemoveDBFile()
RemoveLogFile()
//WriteLog([]byte, int32)
WriteLog([]byte)
ReadLog([]byte, int32, *uint32) bool
GetLogFileSize() int64
GCLogFile() error
}
*
- DiskManager takes care of the allocation and deallocation of pages within a database. It performs the reading and
- writing of pages to and from disk, providing a logical file layer within the context of a database management system.
func NewDiskManagerImpl ¶
func NewDiskManagerImpl(dbFilename string) DiskManager
NewDiskManagerImpl returns a DiskManager instance
func NewDiskManagerTest ¶
func NewDiskManagerTest() DiskManager
NewDiskManagerTest returns a DiskManager instance for testing purposes
func NewVirtualDiskManagerImpl ¶ added in v0.0.2
func NewVirtualDiskManagerImpl(dbFilename string) DiskManager
type DiskManagerImpl ¶
type DiskManagerImpl struct {
// contains filtered or unexported fields
}
DiskManagerImpl is the disk implementation of DiskManager
func (*DiskManagerImpl) AllocatePage ¶
func (d *DiskManagerImpl) AllocatePage() types.PageID
AllocatePage allocates a new page
func (*DiskManagerImpl) DeallocatePage ¶
func (d *DiskManagerImpl) DeallocatePage(pageID types.PageID)
DeallocatePage deallocates page Need bitmap in header page for tracking pages This does not actually need to do anything for now.
func (*DiskManagerImpl) GCLogFile ¶ added in v0.0.2
func (d *DiskManagerImpl) GCLogFile() error
erase needless data from log file (use this when db recovery finishes or snapshot finishes) file content becomes empty
func (*DiskManagerImpl) GetLogFileSize ¶
func (d *DiskManagerImpl) GetLogFileSize() int64
*
- Private helper function to get disk file size
func (*DiskManagerImpl) GetNumWrites ¶
func (d *DiskManagerImpl) GetNumWrites() uint64
GetNumWrites returns the number of disk writes
func (*DiskManagerImpl) ReadLog ¶
func (d *DiskManagerImpl) ReadLog(log_data []byte, offset int32, retReadBytes *uint32) bool
* * Read the contents of the log into the given memory area * Always read from the beginning and perform sequence read * @return: false means already reach the end
Attention: len(log_data) specifies read data length
func (*DiskManagerImpl) ReadPage ¶
func (d *DiskManagerImpl) ReadPage(pageID types.PageID, pageData []byte) error
Read a page from the database file
func (*DiskManagerImpl) RemoveDBFile ¶
func (d *DiskManagerImpl) RemoveDBFile()
ATTENTION: this method can be call after calling of Shutdown method
func (*DiskManagerImpl) RemoveLogFile ¶
func (d *DiskManagerImpl) RemoveLogFile()
ATTENTION: this method can be call after calling of Shutdown method
func (*DiskManagerImpl) ShutDown ¶
func (d *DiskManagerImpl) ShutDown()
ShutDown closes of the database file
func (*DiskManagerImpl) Size ¶
func (d *DiskManagerImpl) Size() int64
Size returns the size of the file in disk
func (*DiskManagerImpl) WriteLog ¶
func (d *DiskManagerImpl) WriteLog(log_data []byte)
*
- Write the contents of the log into disk file
- Only return when sync is done, and only perform sequence write
type DiskManagerTest ¶
type DiskManagerTest struct {
DiskManager
// contains filtered or unexported fields
}
DiskManagerTest is the disk implementation of DiskManager for testing purposes
func (*DiskManagerTest) ShutDown ¶
func (d *DiskManagerTest) ShutDown()
ShutDown closes of the database file
type VirtualDiskManagerImpl ¶ added in v0.0.2
type VirtualDiskManagerImpl struct {
// contains filtered or unexported fields
}
DiskManagerImpl is the disk implementation of DiskManager
func (*VirtualDiskManagerImpl) AllocatePage ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) AllocatePage() types.PageID
AllocatePage allocates a new page
func (*VirtualDiskManagerImpl) DeallocatePage ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) DeallocatePage(pageID types.PageID)
DeallocatePage deallocates page Need bitmap in header page for tracking pages This does not actually need to do anything for now.
func (*VirtualDiskManagerImpl) GCLogFile ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) GCLogFile() error
erase needless data from log file (use this when db recovery finishes or snapshot finishes) file content becomes empty
func (*VirtualDiskManagerImpl) GetLogFileSize ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) GetLogFileSize() int64
*
- Private helper function to get disk file size
func (*VirtualDiskManagerImpl) GetNumWrites ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) GetNumWrites() uint64
GetNumWrites returns the number of disk writes
func (*VirtualDiskManagerImpl) ReadLog ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) ReadLog(log_data []byte, offset int32, retReadBytes *uint32) bool
* * Read the contents of the log into the given memory area * Always read from the beginning and perform sequence read * @return: false means already reach the end
Attention: len(log_data) specifies read data length
func (*VirtualDiskManagerImpl) ReadPage ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) ReadPage(pageID types.PageID, pageData []byte) error
Read a page from the database file
func (*VirtualDiskManagerImpl) RemoveDBFile ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) RemoveDBFile()
ATTENTION: this method can be call after calling of Shutdown method
func (*VirtualDiskManagerImpl) RemoveLogFile ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) RemoveLogFile()
ATTENTION: this method can be call after calling of Shutdown method
func (*VirtualDiskManagerImpl) ShutDown ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) ShutDown()
ShutDown closes of the database file
func (*VirtualDiskManagerImpl) Size ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) Size() int64
Size returns the size of the file in disk
func (*VirtualDiskManagerImpl) WriteLog ¶ added in v0.0.2
func (d *VirtualDiskManagerImpl) WriteLog(log_data []byte)
*
- Write the contents of the log into disk file
- Only return when sync is done, and only perform sequence write