Esempio n. 1
0
 /**
  * Delete the specified tuple from the page; the tuple should be updated to reflect that it is no
  * longer stored on any page.
  *
  * @throws DbException if this tuple is not on this page, or tuple slot is already empty.
  * @param t The tuple to delete
  */
 public void deleteTuple(Tuple t) throws DbException {
   // some code goes here
   // not necessary for lab1
   RecordId targetrid = t.getRecordId();
   int tslotnum = targetrid.tupleno();
   if (!targetrid.getPageId().equals(pid) || !isSlotUsed(tslotnum)) {
     throw new DbException("Either wrong page number or requested tuple didn't exist");
   }
   markSlotUsed(tslotnum, false);
   tuples[tslotnum] = null;
 }
Esempio n. 2
0
 // see DbFile.java for javadocs
 public Page deleteTuple(TransactionId tid, Tuple t)
     throws DbException, TransactionAbortedException {
   // some code goes here
   BufferPool bp = Database.getBufferPool();
   RecordId rid = t.getRecordId();
   if (rid == null) {
     throw new DbException("Tuple is not a member of this file");
   }
   HeapPage p = (HeapPage) bp.getPage(tid, rid.getPageId(), Permissions.READ_WRITE);
   p.deleteTuple(t);
   return p;
 }