edu.harvard.deas.hyperenc.vsat
Class NNPageDatabase

java.lang.Object
  extended by java.lang.Thread
      extended by edu.harvard.deas.hyperenc.vsat.NNPageDatabase
All Implemented Interfaces:
PageDatabase, Serializable, Runnable

public class NNPageDatabase
extends Thread
implements Serializable, PageDatabase

Contains an index of the pages we will provide. Does the book-keeping to make sure that each page is only accessed twice, returns pages based on the Nearest Neighbor lookup

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int MAX_NUM_PAGES
          The number of pages this database will contain
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NNPageDatabase()
          Creates a new NNPageDatabase.
 
Method Summary
 byte[] getClosestPage(int key)
          Equivalent to getPage.
 int getMaxPages()
           
 int getNumPages()
           
 byte[] getPage(int key)
          Use the key to return the closest available page.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_NUM_PAGES

public static final int MAX_NUM_PAGES
The number of pages this database will contain

See Also:
Constant Field Values
Constructor Detail

NNPageDatabase

public NNPageDatabase()
Creates a new NNPageDatabase. Generates MAX_NUM_PAGES and inserts them into the database.

Method Detail

getNumPages

public int getNumPages()
Specified by:
getNumPages in interface PageDatabase
Returns:
Number of pages currently stored in the page database.

getMaxPages

public int getMaxPages()
Specified by:
getMaxPages in interface PageDatabase
Returns:
Maximum number of pages that can be stored in the page database.

getClosestPage

public byte[] getClosestPage(int key)
Equivalent to getPage.


getPage

public byte[] getPage(int key)
Use the key to return the closest available page.

Specified by:
getPage in interface PageDatabase
Parameters:
key - The key we are trying to match.
Returns:
The page whose key was closest to the request, or null if the database is empty.