Package org.terrier.matching
Class AccumulatorResultSet
- java.lang.Object
-
- org.terrier.matching.AccumulatorResultSet
-
- All Implemented Interfaces:
java.io.Serializable,ResultSet
public class AccumulatorResultSet extends java.lang.Object implements ResultSet, java.io.Serializable
A result set instance that uses maps internally until initialise() is called- Since:
- 3.0
- Author:
- Nicola Tonelotto
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanarraysInitialisedint[]docidsdocid[]protected intexactResultSizeprotected java.util.concurrent.locks.Locklockprotected booleanmapsInitialisedshort[]occurrencesoccurrencesgnu.trove.TIntShortHashMapoccurrencesMapoccurrence mapprotected intresultSizedouble[]scoresscores[]gnu.trove.TIntDoubleHashMapscoresMapscore mapprotected intstatusCode
-
Constructor Summary
Constructors Constructor Description AccumulatorResultSet(int numberOfDocuments)Constructs an instance of the AccumulatorResultSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetaItem(java.lang.String name, int docid, java.lang.String value)UnsupportedvoidaddMetaItems(java.lang.String name, java.lang.String[] values)Unsupportedjava.lang.String[][]allMetaItems()UnsupportedAccumulatorResultSetgetAccumulatorResultSet(int start, int length)int[]getDocids()Returns the documents ids after retrievalintgetExactResultSize()Returns the exact size of the result set.java.util.concurrent.locks.LockgetLock()get lockjava.lang.StringgetMetaItem(java.lang.String name, int docid)Unsupportedjava.lang.String[]getMetaItems(java.lang.String name)Unsupportedjava.lang.String[]getMetaKeys()Unsupportedshort[]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()get status codebooleanhasMetaItems(java.lang.String name)Unsupportedvoidinitialise()This method initialises the arrays to be sorted, after the matching phase has been completedvoidinitialise(double[] scs)UnsupportedvoidsetExactResultSize(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)set status codevoidsort()Sorts all documents in this resultset by descending scorevoidsort(int topDocs)Sorts the top topDocs document in this resultset be first.
-
-
-
Field Detail
-
docids
public int[] docids
docid[]
-
scores
public double[] scores
scores[]
-
occurrences
public short[] occurrences
occurrences
-
arraysInitialised
protected boolean arraysInitialised
-
scoresMap
public gnu.trove.TIntDoubleHashMap scoresMap
score map
-
occurrencesMap
public gnu.trove.TIntShortHashMap occurrencesMap
occurrence map
-
mapsInitialised
protected boolean mapsInitialised
-
resultSize
protected int resultSize
-
exactResultSize
protected int exactResultSize
-
lock
protected java.util.concurrent.locks.Lock lock
-
statusCode
protected int statusCode
-
-
Method Detail
-
getLock
public java.util.concurrent.locks.Lock getLock()
get lock
-
getStatusCode
public int getStatusCode()
get status code- 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)
set status code- Specified by:
setStatusCodein interfaceResultSet- Parameters:
_statusCode- - the code to return to the user
-
initialise
public void initialise()
This method initialises the arrays to be sorted, after the matching phase has been completed- Specified by:
initialisein interfaceResultSet
-
initialise
public void initialise(double[] scs)
Unsupported- Specified by:
initialisein interfaceResultSet- Parameters:
scs- double[] the scores to initiliase the result set with.
-
getDocids
public int[] getDocids()
Returns the documents ids after retrieval
-
getResultSize
public int getResultSize()
Returns the effective size of the result set.- Specified by:
getResultSizein interfaceResultSet- Returns:
- int the effective size of the result set
-
getOccurrences
public short[] getOccurrences()
Returns the occurrences array.- Specified by:
getOccurrencesin interfaceResultSet- Returns:
- short[] the array the occurrences array.
-
getExactResultSize
public int getExactResultSize()
Returns the exact size of the result set.- Specified by:
getExactResultSizein interfaceResultSet- Returns:
- int the exact size of the result set
-
getScores
public double[] getScores()
Returns the documents scores after retrieval
-
setResultSize
public void setResultSize(int newResultSize)
Sets 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.
-
setExactResultSize
public void setExactResultSize(int newExactResultSize)
Sets 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.
-
sort
public void sort()
Description copied from interface:ResultSetSorts all documents in this resultset by descending score
-
sort
public void sort(int topDocs)
Description copied from interface:ResultSetSorts the top topDocs document in this resultset be first. The order of the remaining documents is undefined.
-
addMetaItem
public void addMetaItem(java.lang.String name, int docid, java.lang.String value)Unsupported- 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)Unsupported- 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)Unsupported- 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)
Unsupported- 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)
Unsupported- Specified by:
hasMetaItemsin interfaceResultSet- Parameters:
name- of the desired metaitem set- Returns:
- true if the set exists.
-
getMetaKeys
public java.lang.String[] getMetaKeys()
Unsupported- Specified by:
getMetaKeysin interfaceResultSet- Returns:
- the list of key names
-
allMetaItems
public java.lang.String[][] allMetaItems()
Unsupported- Specified by:
allMetaItemsin interfaceResultSet
-
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)
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:
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.
-
getAccumulatorResultSet
public AccumulatorResultSet getAccumulatorResultSet(int start, int length)
- Parameters:
start- the starting offsetlength- the number of results to keep- See Also:
Returns a ResultSet starting at the pre-determined position, of the specified size.
-
-