|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.ucsb.adl.middleware.ResultSet
A result set, i.e., the results of a query. A result set stores:
This class maintains a global registry of all result sets. Result sets have fixed lifetimes (starting from completion time); a "reaper" thread may be started that periodically releases result sets whose lifetimes have expired. The reaper thread is also capable of compressing individual results that have not been accessed for a specified period of time.
All methods of this class are multithread-safe.
$Log: ResultSet.java,v $
Revision 1.5 2007/02/14 17:46:48 gjanee
Added support for result set sharing. Added method
reuse.
Revision 1.4 2004/03/15 17:54:40 gjanee
Added support for compression of results. Added an
autoCompress argument to the constructor and a
compressionAge argument to method
startReaper. Rewrote the reaper logic to avoid a
potential deadlock problem. Fixed a bug that was causing the
reaper to hold on to released result sets for an extra cycle.
Revision 1.3 2004/03/05 23:29:43 gjanee
Added support for multiple middleware instances. A middleware
instance is represented by a Global object that is
tied to a main middleware configuration file. All service objects
now maintain a reference to the appropriate Global
object. Instance-wide variables formerly coded as class variables
are now held by the Global object; various methods
that return instance-wide variables now accept a
Global object as an argument. The Global
object is now passed to all service drivers.
Revision 1.2 2003/06/05 22:31:19 gjanee
Query results are now Result objects, i.e., triplets
of standard metadata views.
Revision 1.1 1999/12/03 00:19:04 gjanee
Initial revision
| Constructor Summary | |
ResultSet(edu.ucsb.adl.middleware.Global global,
edu.ucsb.adl.middleware.Query query,
long lifetime,
boolean autoCompress)
Constructs a result set. |
|
| Method Summary | |
void |
addResult(edu.ucsb.adl.middleware.Result result)
Adds a result to the result set. |
void |
addResults(edu.ucsb.adl.middleware.Result[] results)
Adds an array of results to the result set. |
static edu.ucsb.adl.middleware.ResultSet[] |
getAllInstances(edu.ucsb.adl.middleware.Global global)
Returns all result sets in the global registry. |
long |
getCompletionTime()
Returns the result set's completion time. |
long |
getCreationTime()
Returns the result set's creation time. |
java.lang.Exception |
getException()
Returns the exception that terminated the associated query. |
int |
getID()
Returns the result set's ID. |
static edu.ucsb.adl.middleware.ResultSet |
getInstance(edu.ucsb.adl.middleware.Global global,
int id)
Locates a result set in the global registry. |
int |
getNumResults()
Returns the current number of results in the result set. |
edu.ucsb.adl.middleware.Query |
getQuery()
Returns the query associated with the result set. |
edu.ucsb.adl.middleware.Result |
getResult(int index)
Returns a result from the result set. |
edu.ucsb.adl.middleware.Result[] |
getResults(int from,
int to)
Returns a range of results from the result set. |
int |
getTotalResultCount()
Returns the total result count. |
boolean |
isComplete()
Tests if the result set is complete. |
void |
release()
Removes the result set from the global registry. |
static edu.ucsb.adl.middleware.ResultSet |
reuse(edu.ucsb.adl.middleware.Global global,
edu.ucsb.adl.middleware.Query query)
Returns an existing result set whose associated query exactly textually matches a given query, or returns null. |
void |
setComplete(int totalResultCount,
java.lang.Exception exception)
Signals that the result set is complete. |
static void |
startReaper(edu.ucsb.adl.middleware.Global global,
long cycleTime,
long compressionAge)
Starts the reaper thread. |
void |
waitForCompletion()
Returns when the result set is complete. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ResultSet(edu.ucsb.adl.middleware.Global global,
edu.ucsb.adl.middleware.Query query,
long lifetime,
boolean autoCompress)
global - The global object representing this instance of the middleware.query - The associated query.lifetime - The result set's lifetime in milliseconds.autoCompress - A boolean indicating if results should automatically be
compressed as they are added to the result set.
java.lang.NullPointerException - If global or query is null.
java.lang.IllegalArgumentException - If lifetime is negative.
java.lang.IllegalStateException - If all IDs are in use, which is highly unlikely.| Method Detail |
public static edu.ucsb.adl.middleware.ResultSet getInstance(edu.ucsb.adl.middleware.Global global,
int id)
global - The global object representing this instance of the middleware.id - The desired result set's ID.
null if there is no such result
set.public static edu.ucsb.adl.middleware.ResultSet[] getAllInstances(edu.ucsb.adl.middleware.Global global)
global - The global object representing this instance of the middleware.
public int getID()
public long getCreationTime()
System.currentTimeMillis.public edu.ucsb.adl.middleware.Query getQuery()
public int getNumResults()
public edu.ucsb.adl.middleware.Result getResult(int index)
index - The index of the result to return.
java.lang.ArrayIndexOutOfBoundsException - If index is out of bounds.
public edu.ucsb.adl.middleware.Result[] getResults(int from,
int to)
from - The starting index, inclusive.to - The ending index, exclusive.
java.lang.ArrayIndexOutOfBoundsException - If from or to are out of bounds or if
from is greater than to.public void addResult(edu.ucsb.adl.middleware.Result result)
result - The query result.
java.lang.NullPointerException - If result is null.
java.lang.IllegalStateException - If the result set is already complete.public void addResults(edu.ucsb.adl.middleware.Result[] results)
results - The results to add, i.e., an array of Results.
java.lang.NullPointerException - If results is null or if any element
of results is null.
java.lang.IllegalStateException - If the result set is already complete.public boolean isComplete()
true if the result set is complete.public long getCompletionTime()
System.currentTimeMillis or a negative value if
the result set is incomplete.public int getTotalResultCount()
public java.lang.Exception getException()
null if the query completed
successfully or the result set is incomplete.
public void setComplete(int totalResultCount,
java.lang.Exception exception)
totalResultCount - The total number of results, or a negative value if the total
number is unknown.exception - The exception that terminated the associated query, or
null if the query terminated successfully.
java.lang.IllegalArgumentException - If totalResultCount is nonnegative and less than
the current size of the result set.
java.lang.IllegalStateException - If the result set is already complete.public void waitForCompletion()
public void release()
public static edu.ucsb.adl.middleware.ResultSet reuse(edu.ucsb.adl.middleware.Global global,
edu.ucsb.adl.middleware.Query query)
null.
If a result set is found, and if the result set is complete,
its age is effectively reset to zero.
global - The global object representing this instance of the middleware.query - The query to match.
ResultSet, or null.
public static void startReaper(edu.ucsb.adl.middleware.Global global,
long cycleTime,
long compressionAge)
global - The global object representing this instance of the middleware.cycleTime - The duration of the reaper's cycle in milliseconds.compressionAge - The age in milliseconds at which query results are compressed
by the reaper. If negative, the reaper never compresses
results. A query result's age is reset to zero each time a
metadata view is requested from the result.
java.lang.IllegalArgumentException - If cycleTime is negative.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||