Package org.terrier.matching.daat
Class CandidateResultSet
- java.lang.Object
-
- org.terrier.matching.daat.CandidateResultSet
-
- All Implemented Interfaces:
java.io.Serializable,ResultSet
- Direct Known Subclasses:
FatCandidateResultSet
public class CandidateResultSet extends java.lang.Object implements ResultSet, java.io.Serializable
ResultSet which is created from a set of CandidateResults. Used by DAAT matching strategies.- Since:
- 3.5
- Author:
- Nicola Tonellotto
- See Also:
CandidateResult, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]docidsprotected intexactResultSizeprotected java.util.concurrent.locks.Locklockprotected short[]occurrencesprotected intresultSizeprotected double[]scoresprotected intstatusCode
-
Constructor Summary
Constructors Modifier Constructor Description protectedCandidateResultSet()CandidateResultSet(java.util.Collection<CandidateResult> _q)Create a ResultSet from the specified queue of resultsCandidateResultSet(java.util.List<CandidateResult> _q)Create a ResultSet from the specified list of results
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetaItem(java.lang.String name, int docid, java.lang.String value)Adds a metadata value for a given documentvoidaddMetaItems(java.lang.String name, java.lang.String[] values)Adds the metadata values for all the documents in the result set.java.lang.String[][]allMetaItems()int[]getDocids()Returns the documents ids after retrievalintgetExactResultSize()Returns the exact size of the result set.java.util.concurrent.locks.LockgetLock()Returns the lock associated with the result set.java.lang.StringgetMetaItem(java.lang.String name, int docid)Gets a metadata value for a given document.java.lang.String[]getMetaItems(java.lang.String name)Gets the metadata information for all documents.java.lang.String[]getMetaKeys()Returns the names of the meta keys which this resultset hasshort[]getOccurrences()Returns the occurrences array.ResultSetgetResultSet(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.ResultSetgetResultSet(int start, int length)Crops the existing result file and extracts a subset from the given starting point, with the given length.intgetResultSize()Returns the effective size of the result set.double[]getScores()Returns the documents scores after retrievalintgetStatusCode()Returns a status code for the result setbooleanhasMetaItems(java.lang.String name)Returns true if the resultset already has a set of metaitems with the specified name.voidinitialise()Initialises the arrays prior of retrieval.voidinitialise(double[] scs)Initialises the result set with the given scores.voidsetExactResultSize(int newExactResultSize)Sets the exact size of the result set, that is the number of documents that contain at least one query term.voidsetResultSize(int newResultSize)Sets the effective size of the result set, that is the number of documents to be sorted after retrieval.voidsetStatusCode(int _statusCode)Sets the status code.voidsort()Sorts all documents in this resultset by descending scorevoidsort(int topDocs)Sorts the top topDocs document in this resultset be first.
-
-
-
Constructor Detail
-
CandidateResultSet
protected CandidateResultSet()
-
CandidateResultSet
public CandidateResultSet(java.util.Collection<CandidateResult> _q)
Create a ResultSet from the specified queue of results
-
CandidateResultSet
public CandidateResultSet(java.util.List<CandidateResult> _q)
Create a ResultSet from the specified list of results
-
-
Method Detail
-
getLock
public java.util.concurrent.locks.Lock getLock()
Returns the lock associated with the result set. The lock is used for modifying the result set concurrently by more than one threads.
-
getStatusCode
public int getStatusCode()
Returns a status code for the result set- Specified by:
getStatusCodein interfaceResultSet- Returns:
- a integer status code. 0 stands success. 1 stands for empty result set. 2 stands for wrong setting of start/end parameters. 3 stands for query timeout. The values assigned to the status codes are increasing accordingly to the severity of the status.
-
setStatusCode
public void setStatusCode(int _statusCode)
Sets the status code.- Specified by:
setStatusCodein interfaceResultSet- Parameters:
_statusCode- - the code to return to the user
-
addMetaItem
public void addMetaItem(java.lang.String name, int docid, java.lang.String value)Description copied from interface:ResultSetAdds a metadata value for a given document- Specified by:
addMetaItemin interfaceResultSet- Parameters:
name- the name of the metadata type. For example, it can be url for adding the URLs of documents.docid- the document identifier of the document.value- the metadata value.
-
addMetaItems
public void addMetaItems(java.lang.String name, java.lang.String[] values)Description copied from interface:ResultSetAdds 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.- Specified by:
addMetaItemsin interfaceResultSet- 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 docid)Description copied from interface:ResultSetGets a metadata value for a given document. If the requested metadata information is not specified, then we return null.- Specified by:
getMetaItemin interfaceResultSet- Parameters:
name- the name of the metadata type.docid- the document identifier of the document.- 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)
Description copied from interface:ResultSetGets the metadata information for all documents. If the requested metadata information is not specified, then we return null.- Specified by:
getMetaItemsin interfaceResultSet- 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.
-
hasMetaItems
public boolean hasMetaItems(java.lang.String name)
Description copied from interface:ResultSetReturns true if the resultset already has a set of metaitems with the specified name.- Specified by:
hasMetaItemsin interfaceResultSet- Parameters:
name- of the desired metaitem set- Returns:
- true if the set exists.
-
getMetaKeys
public java.lang.String[] getMetaKeys()
Description copied from interface:ResultSetReturns the names of the meta keys which this resultset has- Specified by:
getMetaKeysin interfaceResultSet- Returns:
- the list of key names
-
allMetaItems
public java.lang.String[][] allMetaItems()
- Specified by:
allMetaItemsin interfaceResultSet
-
getDocids
public int[] getDocids()
Description copied from interface:ResultSetReturns the documents ids after retrieval
-
getScores
public double[] getScores()
Description copied from interface:ResultSetReturns the documents scores after retrieval
-
getOccurrences
public short[] getOccurrences()
Description copied from interface:ResultSetReturns the occurrences array.- Specified by:
getOccurrencesin interfaceResultSet- Returns:
- short[] the array the occurrences array.
-
getResultSize
public int getResultSize()
Description copied from interface:ResultSetReturns the effective size of the result set.- Specified by:
getResultSizein interfaceResultSet- Returns:
- int the effective size of the result set
-
getExactResultSize
public int getExactResultSize()
Description copied from interface:ResultSetReturns the exact size of the result set.- Specified by:
getExactResultSizein interfaceResultSet- Returns:
- int the exact size of the result set
-
getResultSet
public ResultSet getResultSet(int start, int length)
Crops the existing result file and extracts a subset from the given starting point, with the given length.- Specified by:
getResultSetin interfaceResultSet- Parameters:
start- the beginning of the subset.length- the length of the subset.- Returns:
- a subset of the current result set.
-
getResultSet
public ResultSet getResultSet(int[] positions)
Description copied from interface:ResultSetExtracts 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:
getResultSetin interfaceResultSet- Parameters:
positions- the list of elements in the current list that should be kept.- Returns:
- a subset of the current result set specified by the list.
-
initialise
public void initialise()
Description copied from interface:ResultSetInitialises the arrays prior of retrieval.- Specified by:
initialisein interfaceResultSet
-
initialise
public void initialise(double[] scs)
Description copied from interface:ResultSetInitialises the result set with the given scores. If the length of the given array is different than the length of the internal arrays, then we re-allocate memory and create the arrays.- Specified by:
initialisein interfaceResultSet- Parameters:
scs- double[] the scores to initiliase the result set with.
-
setExactResultSize
public void setExactResultSize(int newExactResultSize)
Description copied from interface:ResultSetSets the exact size of the result set, that is the number of documents that contain at least one query term.- Specified by:
setExactResultSizein interfaceResultSet- Parameters:
newExactResultSize- int the effective size of the result set.
-
setResultSize
public void setResultSize(int newResultSize)
Description copied from interface:ResultSetSets the effective size of the result set, that is the number of documents to be sorted after retrieval.- Specified by:
setResultSizein interfaceResultSet- Parameters:
newResultSize- int the effective size of the result set.
-
sort
public void sort()
Description copied from interface:ResultSetSorts all documents in this resultset by descending score
-
-