Terrier IR Platform
2.2.1

uk.ac.gla.terrier.matching
Class QueryResultSet

java.lang.Object
  extended by uk.ac.gla.terrier.matching.CollectionResultSet
      extended by uk.ac.gla.terrier.matching.QueryResultSet
All Implemented Interfaces:
java.io.Serializable, ResultSet

public class QueryResultSet
extends CollectionResultSet

A result set for a given query. This result set is created for a given number of documents, usually the number of retrieved documents for a query. Initially, it is created by cropping an instance of the CollectionResultSet, that is used in the Matching classes.
This class has support for adding metadata as well.

Version:
$Revision: 1.23 $
Author:
Vassilis Plachouras, Craig Macdonald
See Also:
Serialized Form

Constructor Summary
QueryResultSet(int numberOfDocuments)
          A default constructor for the result set with a given number of documents.
 
Method Summary
 void addMetaItem(java.lang.String name, int index, java.lang.String value)
          Adds a metadata value for a given document
 void addMetaItems(java.lang.String name, java.lang.String[] values)
          Adds the metadata values for all the documents in the result set.
 java.lang.String getMetaItem(java.lang.String name, int index)
          Gets a metadata value for a given document.
 java.lang.String[] getMetaItems(java.lang.String name)
          Gets the metadata information for all documents.
 ResultSet getResultSet(int[] positions)
          Extracts a subset of the resultset given by the list parameter, which contains a list of positions in the resultset that should be saved.
 ResultSet getResultSet(int startPosition, int length)
          Crops the existing result file and extracts a subset from the given starting point to the ending point.
 void initialise()
          Initialises the arrays prior of retrieval.
 
Methods inherited from class uk.ac.gla.terrier.matching.CollectionResultSet
getDocids, getExactResultSize, getLock, getOccurrences, getResultSize, getScores, getStatusCode, initialise, setExactResultSize, setResultSize, setStatusCode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryResultSet

public QueryResultSet(int numberOfDocuments)
A default constructor for the result set with a given number of documents.

Parameters:
numberOfDocuments - the number of documents contained in the result set.
Method Detail

initialise

public void initialise()
Initialises the arrays prior of retrieval. Only the first time it is called, it will allocate memory for the arrays.

Specified by:
initialise in interface ResultSet
Overrides:
initialise in class CollectionResultSet

addMetaItem

public void addMetaItem(java.lang.String name,
                        int index,
                        java.lang.String value)
Adds a metadata value for a given document

Specified by:
addMetaItem in interface ResultSet
Overrides:
addMetaItem in class CollectionResultSet
Parameters:
name - the name of the metadata type. For example, it can be url for adding the URLs of documents.
index - the position in the resultset array of the given document
value - the metadata value.

addMetaItems

public void addMetaItems(java.lang.String name,
                         java.lang.String[] values)
Adds the metadata values for all the documents in the result set. The length of the metadata array values should be equal to the length of the docids array. The array must be sorted in the same way as the resultset (ascending score)

Specified by:
addMetaItems in interface ResultSet
Overrides:
addMetaItems in class CollectionResultSet
Parameters:
name - the name of the metadata type. For example, it can be url for adding the URLs of documents.
values - the metadata values.

getMetaItem

public java.lang.String getMetaItem(java.lang.String name,
                                    int index)
Gets a metadata value for a given document. If the requested metadata information is not specified, then we return null.

Specified by:
getMetaItem in interface ResultSet
Overrides:
getMetaItem in class CollectionResultSet
Parameters:
name - the name of the metadata type.
index - the postition in the array
Returns:
a string with the metadata information, or null of the metadata is not available.

getMetaItems

public java.lang.String[] getMetaItems(java.lang.String name)
Gets the metadata information for all documents. If the requested metadata information is not specified, then we return null.

Specified by:
getMetaItems in interface ResultSet
Overrides:
getMetaItems in class CollectionResultSet
Parameters:
name - the name of the metadata type.
Returns:
an array of strings with the metadata information, or null of the metadata is not available.

getResultSet

public ResultSet getResultSet(int startPosition,
                              int length)
Crops the existing result file and extracts a subset from the given starting point to the ending point.

Specified by:
getResultSet in interface ResultSet
Overrides:
getResultSet in class CollectionResultSet
Parameters:
startPosition - the beginning of the subset.
length - the number of entries to get.
Returns:
a subset of the current result set.

getResultSet

public ResultSet getResultSet(int[] positions)
Extracts a subset of the resultset given by the list parameter, which contains a list of positions in the resultset that should be saved.

Specified by:
getResultSet in interface ResultSet
Overrides:
getResultSet in class CollectionResultSet
Parameters:
positions - int[] the list of elements in the current list that should be kept.
Returns:
a subset of the current result set specified by the list.

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow