simpledb
Class Catalog

java.lang.Object
  extended by simpledb.Catalog

public class Catalog
extends java.lang.Object

The Catalog keeps track of all available tables in the database and their associated schemas. For now, this is a stub catalog that must be populated with tables by a user program before it can be used -- eventually, this should be converted to a catalog that reads a catalog table from disk.


Constructor Summary
Catalog()
          Constructor.
 
Method Summary
 void addTable(DbFile file, TupleDesc t)
          Add a new table to the catalog.
 void addTable(DbFile file, TupleDesc t, java.lang.String name)
          Add a new table to the catalog.
 void clear()
          Delete all tables from the catalog
 DbFile getDbFile(int tableid)
          Returns the DbFile that can be used to read the contents of the specified table.
 int getTableId(java.lang.String name)
          Return the id of the table with a specified name,
 TupleDesc getTupleDesc(int tableid)
          Returns the tuple descriptor (schema) of the specified table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Catalog

public Catalog()
Constructor. Creates a new, empty catalog.

Method Detail

addTable

public void addTable(DbFile file,
                     TupleDesc t,
                     java.lang.String name)
Add a new table to the catalog. This table has tuples formatted using the specified TupleDesc and its contents are stored in the specified DbFile.

Parameters:
file - the contents of the table to add; file.id() is the identfier of this file/tupledesc param for the calls getTupleDesc and getFile
t - the format of tuples that are being added
name - the name of the table -- may be an empty string. May not be null. If a name conflict exists, use the last table to be added as the table for a given name.

addTable

public void addTable(DbFile file,
                     TupleDesc t)
Add a new table to the catalog. This table has tuples formatted using the specified TupleDesc and its contents are stored in the specified DbFile.

Parameters:
file - the contents of the table to add; file.id() is the identfier of this file/tupledesc param for the calls getTupleDesc and getFile
t - the format of tuples that are being added

getTableId

public int getTableId(java.lang.String name)
Return the id of the table with a specified name,

Throws:
java.util.NoSuchElementException - if the table doesn't exist

getTupleDesc

public TupleDesc getTupleDesc(int tableid)
                       throws java.util.NoSuchElementException
Returns the tuple descriptor (schema) of the specified table

Parameters:
tableid - The id of the table, as specified by the DbFile.id() function passed to addTable
Throws:
java.util.NoSuchElementException

getDbFile

public DbFile getDbFile(int tableid)
                 throws java.util.NoSuchElementException
Returns the DbFile that can be used to read the contents of the specified table.

Parameters:
tableid - The id of the table, as specified by the DbFile.id() function passed to addTable
Throws:
java.util.NoSuchElementException

clear

public void clear()
Delete all tables from the catalog