simpledb
Class HeapPageId

java.lang.Object
  extended by simpledb.HeapPageId
All Implemented Interfaces:
PageId

public class HeapPageId
extends java.lang.Object
implements PageId

Unique identifier for HeapPage objects.


Constructor Summary
HeapPageId(int tableId, int pgNo)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares one PageId to another.
 int getTableId()
           
 int hashCode()
           
 int pageNumber()
           
 int[] serialize()
          Return a representation of this object as an array of integers, for writing to disk.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapPageId

public HeapPageId(int tableId,
                  int pgNo)
Constructor. Create a page id structure for a specific page of a specific table.

Parameters:
tableId - The table that is being referenced
pgNo - The page number in that table.
Method Detail

getTableId

public int getTableId()
Specified by:
getTableId in interface PageId
Returns:
the table associated with this PageId

pageNumber

public int pageNumber()
Specified by:
pageNumber in interface PageId
Returns:
the page number in the table getTableId() associated with this PageId

hashCode

public int hashCode()
Specified by:
hashCode in interface PageId
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this page, represented by the concatenation of the table number and the page number (needed if a PageId is used as a key in a hash table in the BufferPool, for example.)
See Also:
BufferPool

equals

public boolean equals(java.lang.Object o)
Compares one PageId to another.

Specified by:
equals in interface PageId
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare against (must be a PageId)
Returns:
true if the objects are equal (e.g., page numbers and table ids are the same)

serialize

public int[] serialize()
Return a representation of this object as an array of integers, for writing to disk. Size of returned array must contain number of integers that corresponds to number of args to one of the constructors.

Specified by:
serialize in interface PageId