All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class heap.Heapfile

java.lang.Object
   |
   +----heap.Heapfile

public class Heapfile
extends Object
implements Filetype, GlobalConst

Constructor Index

 o Heapfile(String)
Initialize.

Method Index

 o deleteFile()
Delete the file from the database.
 o deleteRecord(RID)
Delete record from file with given rid.
 o getRecCnt()
Return number of records in file.
 o getRecord(RID)
Read record from file, returning pointer and length.
 o insertRecord(byte[])
Insert record into file, return its Rid.
 o openScan()
Initiate a sequential scan.
 o updateRecord(RID, Tuple)
Updates the specified record in the heapfile.

Constructors

 o Heapfile
 public Heapfile(String name) throws HFException, HFBufMgrException, HFDiskMgrException, IOException
Initialize. A null name produces a temporary heapfile which will be deleted by the destructor. If the name already denotes a file, the file is opened; otherwise, a new empty file is created.

Throws: HFException
heapfile exception
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: IOException
I/O errors

Methods

 o getRecCnt
 public int getRecCnt() throws InvalidSlotNumberException, InvalidTupleSizeException, HFDiskMgrException, HFBufMgrException, IOException
Return number of records in file.

Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidTupleSizeException
invalid tuple size
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: IOException
I/O errors
 o insertRecord
 public RID insertRecord(byte recPtr[]) throws InvalidSlotNumberException, InvalidTupleSizeException, SpaceNotAvailableException, HFException, HFBufMgrException, HFDiskMgrException, IOException
Insert record into file, return its Rid.

Parameters:
recPtr - pointer of the record
recLen - the length of the record
Returns:
the rid of the record
Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidTupleSizeException
invalid tuple size
Throws: SpaceNotAvailableException
no space left
Throws: HFException
heapfile exception
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: IOException
I/O errors
 o deleteRecord
 public boolean deleteRecord(RID rid) throws InvalidSlotNumberException, InvalidTupleSizeException, HFException, HFBufMgrException, HFDiskMgrException, Exception
Delete record from file with given rid.

Returns:
true record deleted false:record not found
Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidTupleSizeException
invalid tuple size
Throws: HFException
heapfile exception
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: Exception
other exception
 o updateRecord
 public boolean updateRecord(RID rid,
                             Tuple newtuple) throws InvalidSlotNumberException, InvalidUpdateException, InvalidTupleSizeException, HFException, HFDiskMgrException, HFBufMgrException, Exception
Updates the specified record in the heapfile.

Parameters:
rid: - the record which needs update
newtuple: - the new content of the record
Returns:
ture:update success false: can't find the record
Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidUpdateException
invalid update on record
Throws: InvalidTupleSizeException
invalid tuple size
Throws: HFException
heapfile exception
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: Exception
other exception
 o getRecord
 public Tuple getRecord(RID rid) throws InvalidSlotNumberException, InvalidTupleSizeException, HFException, HFDiskMgrException, HFBufMgrException, Exception
Read record from file, returning pointer and length.

Parameters:
rid - Record ID
Returns:
a Tuple. if Tuple==null, no more tuple
Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidTupleSizeException
invalid tuple size
Throws: SpaceNotAvailableException
no space left
Throws: HFException
heapfile exception
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: Exception
other exception
 o openScan
 public Scan openScan() throws InvalidTupleSizeException, IOException
Initiate a sequential scan.

Throws: InvalidTupleSizeException
Invalid tuple size
Throws: IOException
I/O errors
 o deleteFile
 public void deleteFile() throws InvalidSlotNumberException, FileAlreadyDeletedException, InvalidTupleSizeException, HFBufMgrException, HFDiskMgrException, IOException
Delete the file from the database.

Throws: InvalidSlotNumberException
invalid slot number
Throws: InvalidTupleSizeException
invalid tuple size
Throws: FileAlreadyDeletedException
file is deleted already
Throws: HFBufMgrException
exception thrown from bufmgr layer
Throws: HFDiskMgrException
exception thrown from diskmgr layer
Throws: IOException
I/O errors

All Packages  Class Hierarchy  This Package  Previous  Next  Index