public class StorageManager
extends java.lang.Object
Constructor and Description |
---|
StorageManager(Catalog catalog,
BufferManager buffer)
Initializes a new storage manager, given a catalog and a buffer
pool.
|
Modifier and Type | Method and Description |
---|---|
void |
castAndInsertTuple(java.lang.String tablename,
java.util.List<java.lang.Comparable> values)
Casts the list of comparables to the correct types before
inserting the tuple.
|
void |
castAndInsertTuple(java.lang.String tablename,
Tuple tuple)
Casts the list of comparables to the correct types before
inserting the tuple.
|
void |
createFile(java.lang.String filename)
Create a new file by the given file name.
|
static java.lang.String |
createFileName(Relation relation)
Given a relation, it creates a file name for it.
|
void |
createTable(Table table)
Creates a new table in the database.
|
void |
deleteFile(java.lang.String filename)
Delete the specified file.
|
void |
deleteTable(java.lang.String tablename)
Deletes the specified table from the database.
|
int |
getNumberOfBufferPoolPages()
Returns the number of buffer pool pages.
|
void |
insertTuple(java.lang.String tablename,
java.util.List<java.lang.Comparable> values)
Inserts a new tuple into the given table.
|
void |
insertTuple(java.lang.String tablename,
Tuple tuple)
Inserts a new tuple into the given table.
|
static void |
main(java.lang.String[] args)
Debug main().
|
Page |
readPage(Relation relation,
PageIdentifier pageid)
Reads a page from the database given the page's identifier.
|
void |
registerPage(Page page)
Registers a page with the buffer pool.
|
void |
shutdown() |
void |
writePage(Page page)
Writes a page to disk.
|
public StorageManager(Catalog catalog, BufferManager buffer)
catalog
- this storage mananger's catalog.buffer
- the buffer pool.public void registerPage(Page page) throws StorageManagerException
page
- the page to be registered.StorageManagerException
- if the page cannot be registered.public void writePage(Page page) throws StorageManagerException
page
- the page to be writtenStorageManagerException
- thrown whenever there is an I/O
error.public Page readPage(Relation relation, PageIdentifier pageid) throws StorageManagerException
pageid
- the identifier of the page to be read.StorageManagerException
- whenever something goes wrong with
reading the page.public static java.lang.String createFileName(Relation relation)
relation
- the relation for which a file name is to be created.public void createTable(Table table) throws StorageManagerException
table
- the new table.StorageManagerException
- thrown whenever the table
cannot be created.public void deleteTable(java.lang.String tablename) throws java.util.NoSuchElementException, StorageManagerException
tablename
- the name of the table to be deleted.java.util.NoSuchElementException
- thrown if the table does not
exist.StorageManagerException
- thrown if the file cannot be
deleted.public void createFile(java.lang.String filename) throws StorageManagerException
filename
- the name of the new file.StorageManagerException
- thrown whenever the new file
cannot be deleted.public void deleteFile(java.lang.String filename) throws StorageManagerException
filename
- the name of the file to be deleted.StorageManagerException
- thrown whenever the file cannot be
deleted.public void castAndInsertTuple(java.lang.String tablename, Tuple tuple) throws java.util.NoSuchElementException, StorageManagerException
tablename
- the target table.tuple
- the new tuple.java.util.NoSuchElementException
- thrown whenever the specified table
does not exist.StorageManagerException
- thrown whenever ther insertion is
not possible.public void insertTuple(java.lang.String tablename, Tuple tuple) throws java.util.NoSuchElementException, StorageManagerException
tablename
- the name of the table where the tuple is to
be inserted.tuple
- the new tuple.java.util.NoSuchElementException
- thrown whenever the specified table
does not exist.StorageManagerException
- thrown whenever ther insertion is
not possible.public void castAndInsertTuple(java.lang.String tablename, java.util.List<java.lang.Comparable> values) throws java.util.NoSuchElementException, StorageManagerException
tablename
- the target table.values
- the values to be inserted.java.util.NoSuchElementException
- thrown whenever the specified table
does not exist.StorageManagerException
- thrown whenever ther insertion is
not possible.public void insertTuple(java.lang.String tablename, java.util.List<java.lang.Comparable> values) throws java.util.NoSuchElementException, StorageManagerException
tablename
- the name of the table where the tuple is to
be inserted.values
- the values of the tuple.java.util.NoSuchElementException
- thrown whenever the specified table
does not exist.StorageManagerException
- thrown whenever ther insertion is
not possible.public void shutdown() throws StorageManagerException
StorageManagerException
public int getNumberOfBufferPoolPages()
public static void main(java.lang.String[] args)
args
-