public class Catalog
extends java.lang.Object
Constructor and Description |
---|
Catalog()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addTable(DbFile file)
Add a new table to the catalog.
|
void |
addTable(DbFile file,
java.lang.String name) |
void |
addTable(DbFile file,
java.lang.String name,
java.lang.String pkeyField)
Add a new table to the catalog.
|
void |
clear()
Delete all tables from the catalog
|
DbFile |
getDatabaseFile(int tableid)
Returns the DbFile that can be used to read the contents of the
specified table.
|
java.lang.String |
getPrimaryKey(int tableid) |
int |
getTableId(java.lang.String name)
Return the id of the table with a specified name,
|
java.lang.String |
getTableName(int id) |
TupleDesc |
getTupleDesc(int tableid)
Returns the tuple descriptor (schema) of the specified table
|
void |
loadSchema(java.lang.String catalogFile)
Reads the schema from a file and creates the appropriate tables in the database.
|
java.util.Iterator<java.lang.Integer> |
tableIdIterator() |
public void addTable(DbFile file, java.lang.String name, java.lang.String pkeyField)
file
- the contents of the table to add; file.getId() is the identfier of
this file/tupledesc param for the calls getTupleDesc and getFilename
- 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.pkeyField
- the name of the primary key fieldpublic void addTable(DbFile file, java.lang.String name)
public void addTable(DbFile file)
file
- the contents of the table to add; file.getId() is the identfier of
this file/tupledesc param for the calls getTupleDesc and getFilepublic int getTableId(java.lang.String name) throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if the table doesn't existpublic TupleDesc getTupleDesc(int tableid) throws java.util.NoSuchElementException
tableid
- The id of the table, as specified by the DbFile.getId()
function passed to addTablejava.util.NoSuchElementException
- if the table doesn't existpublic DbFile getDatabaseFile(int tableid) throws java.util.NoSuchElementException
tableid
- The id of the table, as specified by the DbFile.getId()
function passed to addTablejava.util.NoSuchElementException
public java.lang.String getPrimaryKey(int tableid)
public java.util.Iterator<java.lang.Integer> tableIdIterator()
public java.lang.String getTableName(int id)
public void clear()
public void loadSchema(java.lang.String catalogFile)
catalogFile
-