All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class diskmgr.DB

java.lang.Object
   |
   +----diskmgr.DB

public class DB
extends Object
implements GlobalConst

Constructor Index

 o DB()
default constructor.

Method Index

 o add_file_entry(String, PageId)
Adds a file entry to the header page(s).
 o allocate_page(PageId)
Allocate a set of pages where the run size is taken to be 1 by default.
 o allocate_page(PageId, int)
user specified run_size
 o closeDB()
Close DB file.
 o db_name()
Functions to return some characteristics of the database.
 o db_num_pages()
 o db_page_size()
 o DBDestroy()
Destroy the database, removing the file that stores it.
 o deallocate_page(PageId)
Deallocate a set of pages starting at the specified page number with run size = 1
 o deallocate_page(PageId, int)
Deallocate a set of pages starting at the specified page number and a run size can be specified.
 o delete_file_entry(String)
Delete the entry corresponding to a file from the header page(s).
 o dump_space_map()
Print out the space map of the database.
 o get_file_entry(String)
Get the entry corresponding to the given file.
 o openDB(String)
Open the database with the given name.
 o openDB(String, int)
DB Constructors.
 o read_page(PageId, Page)
Read the contents of the specified page into a Page object
 o write_page(PageId, Page)
Write the contents in a page object to the specified page.

Constructors

 o DB
 public DB()
default constructor.

Methods

 o openDB
 public void openDB(String fname) throws IOException, InvalidPageNumberException, FileIOException, DiskMgrException
Open the database with the given name.

Parameters:
name - DB_name
Throws: IOException
I/O errors
Throws: FileIOException
file I/O error
Throws: InvalidPageNumberException
invalid page number
Throws: DiskMgrException
error caused by other layers
 o openDB
 public void openDB(String fname,
                    int num_pgs) throws IOException, InvalidPageNumberException, FileIOException, DiskMgrException
DB Constructors. Create a database with the specified number of pages where the page size is the default page size.

Parameters:
name - DB name
num_pages - number of pages in DB
Throws: IOException
I/O errors
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: DiskMgrException
error caused by other layers
 o closeDB
 public void closeDB() throws IOException
Close DB file.

Throws: IOException
I/O errors.
 o DBDestroy
 public void DBDestroy() throws IOException
Destroy the database, removing the file that stores it.

Throws: IOException
I/O errors.
 o read_page
 public void read_page(PageId pageno,
                       Page apage) throws InvalidPageNumberException, FileIOException, IOException
Read the contents of the specified page into a Page object

Parameters:
pageno - pageId which will be read
apage - page object which holds the contents of page
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
 o write_page
 public void write_page(PageId pageno,
                        Page apage) throws InvalidPageNumberException, FileIOException, IOException
Write the contents in a page object to the specified page.

Parameters:
pageno - pageId will be wrote to disk
apage - the page object will be wrote to disk
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
 o allocate_page
 public void allocate_page(PageId start_page_num) throws OutOfSpaceException, InvalidRunSizeException, InvalidPageNumberException, FileIOException, DiskMgrException, IOException
Allocate a set of pages where the run size is taken to be 1 by default. Gives back the page number of the first page of the allocated run. with default run_size =1

Parameters:
start_page_num - page number to start with
Throws: OutOfSpaceException
database is full
Throws: InvalidRunSizeException
invalid run size
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
DB file I/O errors
Throws: IOException
I/O errors
Throws: DiskMgrException
error caused by other layers
 o allocate_page
 public void allocate_page(PageId start_page_num,
                           int runsize) throws OutOfSpaceException, InvalidRunSizeException, InvalidPageNumberException, FileIOException, DiskMgrException, IOException
user specified run_size

Parameters:
start_page_num - the starting page id of the run of pages
run_size - the number of page need allocated
Throws: OutOfSpaceException
No space left
Throws: InvalidRunSizeException
invalid run size
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: DiskMgrException
error caused by other layers
 o deallocate_page
 public void deallocate_page(PageId start_page_num,
                             int run_size) throws InvalidRunSizeException, InvalidPageNumberException, IOException, FileIOException, DiskMgrException
Deallocate a set of pages starting at the specified page number and a run size can be specified.

Parameters:
start_page_num - the start pageId to be deallocate
run_size - the number of pages to be deallocated
Throws: InvalidRunSizeException
invalid run size
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: DiskMgrException
error caused by other layers
 o deallocate_page
 public void deallocate_page(PageId start_page_num) throws InvalidRunSizeException, InvalidPageNumberException, IOException, FileIOException, DiskMgrException
Deallocate a set of pages starting at the specified page number with run size = 1

Parameters:
start_page_num - the start pageId to be deallocate
run_size - the number of pages to be deallocated
Throws: InvalidRunSizeException
invalid run size
Throws: InvalidPageNumberException
invalid page number
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: DiskMgrException
error caused by other layers
 o add_file_entry
 public void add_file_entry(String fname,
                            PageId start_page_num) throws FileNameTooLongException, InvalidPageNumberException, InvalidRunSizeException, DuplicateEntryException, OutOfSpaceException, FileIOException, IOException, DiskMgrException
Adds a file entry to the header page(s).

Parameters:
fname - file entry name
start_page_num - the start page number of the file entry
Throws: FileNameTooLongException
invalid file name (too long)
Throws: InvalidPageNumberException
invalid page number
Throws: InvalidRunSizeException
invalid DB run size
Throws: DuplicateEntryException
entry for DB is not unique
Throws: OutOfSpaceException
database is full
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: DiskMgrException
error caused by other layers
 o delete_file_entry
 public void delete_file_entry(String fname) throws FileEntryNotFoundException, IOException, FileIOException, InvalidPageNumberException, DiskMgrException
Delete the entry corresponding to a file from the header page(s).

Parameters:
fname - file entry name
Throws: FileEntryNotFoundException
file does not exist
Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: InvalidPageNumberException
invalid page number
Throws: DiskMgrException
error caused by other layers
 o get_file_entry
 public PageId get_file_entry(String name) throws IOException, FileIOException, InvalidPageNumberException, DiskMgrException
Get the entry corresponding to the given file.

Parameters:
name - file entry name
Throws: IOException
I/O errors
Throws: FileIOException
file I/O error
Throws: InvalidPageNumberException
invalid page number
Throws: DiskMgrException
error caused by other layers
 o db_name
 public String db_name()
Functions to return some characteristics of the database.

 o db_num_pages
 public int db_num_pages()
 o db_page_size
 public int db_page_size()
 o dump_space_map
 public void dump_space_map() throws DiskMgrException, IOException, FileIOException, InvalidPageNumberException
Print out the space map of the database. The space map is a bitmap showing which pages of the db are currently allocated.

Throws: FileIOException
file I/O error
Throws: IOException
I/O errors
Throws: InvalidPageNumberException
invalid page number
Throws: DiskMgrException
error caused by other layers

All Packages  Class Hierarchy  This Package  Previous  Next  Index