simpledb.file
Class FileMgr

java.lang.Object
  extended by simpledb.file.FileMgr

public class FileMgr
extends Object

The SimpleDB file manager. The database system stores its data as files within a specified directory. The file manager provides methods for reading the contents of a file block to a Java byte buffer, writing the contents of a byte buffer to a file block, and appending the contents of a byte buffer to the end of a file. These methods are called exclusively by the class Page, and are thus package-private. The class also contains two public methods: Method isNew is called during system initialization by SimpleDB.init(java.lang.String). Method size is called by the log manager and transaction manager to determine the end of the file.

Author:
Edward Sciore

Constructor Summary
FileMgr(String dbname)
          Creates a file manager for the specified database.
 
Method Summary
 boolean isNew()
          Returns a boolean indicating whether the file manager had to create a new database directory.
 int size(String filename)
          Returns the number of blocks in the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileMgr

public FileMgr(String dbname)
Creates a file manager for the specified database. The database will be stored in a folder of that name in the user's home directory. If the folder does not exist, then a folder containing an empty database is created automatically. Files for all temporary tables (i.e. tables beginning with "temp") are deleted.

Parameters:
dbname - the name of the directory that holds the database
Method Detail

size

public int size(String filename)
Returns the number of blocks in the specified file.

Parameters:
filename - the name of the file
Returns:
the number of blocks in the file

isNew

public boolean isNew()
Returns a boolean indicating whether the file manager had to create a new database directory.

Returns:
true if the database is new


Copyright © 2011. All Rights Reserved.