edu.ucsb.adl.middleware
Class RankingAccumulator

java.lang.Object
  |
  +--edu.ucsb.adl.middleware.ResultAccumulator
        |
        +--edu.ucsb.adl.middleware.RankingAccumulator

public final class RankingAccumulator
extends ResultAccumulator

A result accumulator that ranks query results before adding them to the associated result set.

This class reads the following properties from the main middleware configuration file. Property values may be indirectly specified using the notation @P where P is the name of another property (see ExtendedProperties for more information).

rankers
The names of all rankers registered to the middleware separated by commas, e.g., "relevance,date,spatial_similarity".
R.name
For ranker R, the descriptive name of the ranker, e.g., "by date, most recent first".
R.class
For ranker R, the fully-qualified name of the ranker class, e.g., "edu.ucsb.adl.middleware.DateRanker".
R.argument
For ranker R, the ranker's startup parameter.

Version:
$Header: /export/home/gjanee/middleware/edu/ucsb/adl/middleware/RCS/RankingAccumulator.java,v 1.6 2004/09/21 23:53:43 gjanee Exp $

$Log: RankingAccumulator.java,v $ Revision 1.6 2004/09/21 23:53:43 gjanee
Minor documentation change.

Revision 1.5 2004/03/11 20:12:20 gjanee
Minor documentation addition.

Revision 1.4 2004/03/05 21:17:57 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.3 2003/06/09 21:04:05 gjanee
Query results are now Result objects, i.e., triplets of standard metadata views.

Revision 1.2 2001/08/17 20:53:56 gjanee
Switched to the new configuration file structure. In the new structure, an entirely collection-independent "main" configuration file refers to a directory of subdirectories, one subdirectory per collection; each subdirectory holds a collection-specific middleware configuration file in addition to any configuration files required by the collection driver.

Revision 1.1 2000/02/27 23:00:46 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Field Summary
 
Fields inherited from class edu.ucsb.adl.middleware.ResultAccumulator
m_maximumResults, m_set
 
Method Summary
protected  void addResultInternal(edu.ucsb.adl.middleware.Result result)
          Ranks a query result and adds it to the internal queue.
static edu.ucsb.adl.middleware.RankingAccumulator createAccumulator(edu.ucsb.adl.middleware.Global global, edu.ucsb.adl.middleware.ResultSet set, int maximumResults, long lifetime, boolean validateResults, java.lang.String rankerName)
          Creates a RankingAccumulator.
protected  void flushToResultSet()
          Flushes query results from the internal queue to the result set.
protected  int getTotalResultCount()
          Returns the total number of query results examined.
static void loadRankers(edu.ucsb.adl.middleware.Global global, edu.ucsb.adl.middleware.ConfigurationFile config)
          Loads ranker descriptions into the global registry.
 
Methods inherited from class edu.ucsb.adl.middleware.ResultAccumulator
addResult, addSource, destroy, getAllInstances, getID, getInstance, getOutstandingSources, isStarted, sourceTerminated, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadRankers

public static void loadRankers(edu.ucsb.adl.middleware.Global global,
                               edu.ucsb.adl.middleware.ConfigurationFile config)
                        throws InternalErrorException
Loads ranker descriptions into the global registry. This method may be called more than once. Duplicate ranker descriptions are ignored.

Parameters:
global - The global object representing this instance of the middleware.
config - The contents of a main middleware configuration file.
Throws:
InternalErrorException - If any error occurs.

createAccumulator

public static edu.ucsb.adl.middleware.RankingAccumulator createAccumulator(edu.ucsb.adl.middleware.Global global,
                                                                           edu.ucsb.adl.middleware.ResultSet set,
                                                                           int maximumResults,
                                                                           long lifetime,
                                                                           boolean validateResults,
                                                                           java.lang.String rankerName)
                                                                    throws MiddlewareException
Creates a RankingAccumulator.

Parameters:
global - The global object representing this instance of the middleware.
set - The associated result set. The result set should be incomplete, and no object other than the accumulator should ever mark it as being complete.
maximumResults - The maximum number of results to accumulate. Note that this is independent of the maximum number of results requested in the associated query.
lifetime - The lifetime of the accumulator in milliseconds.
validateResults - Indicates if query results should be validated.
rankerName - The descriptive name of the ranker to employ, e.g., "by date, most recent first".
Throws:
UnsupportedException - If rankerName is not recognized.
java.lang.NullPointerException - If set or rankerName are null.
java.lang.IllegalArgumentException - If maximumResults or lifetime are negative.
InternalErrorException - If any other error occurs.
MiddlewareException

addResultInternal

protected void addResultInternal(edu.ucsb.adl.middleware.Result result)
Ranks a query result and adds it to the internal queue.

Specified by:
addResultInternal in class ResultAccumulator
Parameters:
result - The result.

flushToResultSet

protected void flushToResultSet()
Flushes query results from the internal queue to the result set.

Specified by:
flushToResultSet in class ResultAccumulator

getTotalResultCount

protected int getTotalResultCount()
Returns the total number of query results examined.

Specified by:
getTotalResultCount in class ResultAccumulator
Returns:
The total number of results.