コード例 #1
0
ファイル: HeapFile.java プロジェクト: DragonZ/cs448
 /**
  * Updates the specified record in the heap file.
  *
  * @throws IllegalArgumentException if the rid or new record is invalid
  */
 public void updateRecord(RID rid, byte[] newRecord) {
   PageId pid = rid.pageno;
   if (!pids.contains(pid.pid)) throw new IllegalArgumentException("the RID is invalid");
   Page page = new Page();
   global.Minibase.BufferManager.pinPage(pid, page, false);
   HFPage hfpage = new HFPage(page);
   if (newRecord.length != hfpage.selectRecord(rid).length) {
     throw new IllegalArgumentException("fail to update RID");
   }
   global.Minibase.BufferManager.unpinPage(rid.pageno, false);
 }
コード例 #2
0
ファイル: HeapFile.java プロジェクト: DragonZ/cs448
 public boolean updateRecord(RID rid, Tuple newTuple) throws ChainException {
   // TODO Auto-generated method stub
   PageId pid = rid.pageno;
   if (!pids.contains(pid.pid)) throw new IllegalArgumentException("the RID is invalid");
   Page page = new Page();
   global.Minibase.BufferManager.pinPage(pid, page, false);
   HFPage hfpage = new HFPage(page);
   if (newTuple.getLength() != hfpage.selectRecord(rid).length) {
     throw new IllegalArgumentException("fail to update RID");
   }
   global.Minibase.BufferManager.unpinPage(rid.pageno, false);
   return true;
 }