Beispiel #1
0
 /**
  * Return the id of the table with a specified name,
  *
  * @throws NoSuchElementException if the table doesn't exist
  */
 public int getTableId(String name) throws NoSuchElementException {
   // some code goes here
   DbFile tableID = tableFile.get(name);
   if (tableID == null) throw new NoSuchElementException();
   // System.out.println(tableID.getId());
   else return tableID.getId();
 }
Beispiel #2
0
 /**
  * Add a new table to the catalog. This table's contents are stored in the specified DbFile.
  *
  * @param file the contents of the table to add; file.getId() is the identfier of this
  *     file/tupledesc param for the calls getTupleDesc and getFile
  * @param name the name of the table -- may be an empty string. May not be null. If a name
  * @param pkeyField the name of the primary key field conflict exists, use the last table to be
  *     added as the table for a given name.
  */
 public void addTable(DbFile file, String name, String pkeyField) throws IllegalArgumentException {
   // some code goes here
   if (file == null || name == null) {
     throw new IllegalArgumentException();
   } else {
     // String[] tableAdd = {name, pkeyField};
     tableFile.put(name, file);
     tablepkey.put(name, pkeyField);
     fileId.put(file.getId(), name);
   }
 }