Documentation
¶
Index ¶
- type DiskManager
- type DiskManagerImpl
- func (d *DiskManagerImpl) AllocatePage() types.PageID
- func (d *DiskManagerImpl) DeallocatePage(pageID types.PageID)
- 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
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
}
*
- 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
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 For now just keep an increasing counter
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) 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