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 boolean
arraysInitialised
int[]
docids
docid[]protected int
exactResultSize
protected java.util.concurrent.locks.Lock
lock
protected boolean
mapsInitialised
short[]
occurrences
occurrencesgnu.trove.TIntShortHashMap
occurrencesMap
occurrence mapprotected int
resultSize
double[]
scores
scores[]gnu.trove.TIntDoubleHashMap
scoresMap
score mapprotected int
statusCode
-
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 void
addMetaItem(java.lang.String name, int docid, java.lang.String value)
Unsupportedvoid
addMetaItems(java.lang.String name, java.lang.String[] values)
Unsupportedjava.lang.String[][]
allMetaItems()
UnsupportedAccumulatorResultSet
getAccumulatorResultSet(int start, int length)
int[]
getDocids()
Returns the documents ids after retrievalint
getExactResultSize()
Returns the exact size of the result set.java.util.concurrent.locks.Lock
getLock()
get lockjava.lang.String
getMetaItem(java.lang.String name, int docid)
Unsupportedjava.lang.String[]
getMetaItems(java.lang.String name)
Unsupportedjava.lang.String[]
getMetaKeys()
Unsupportedshort[]
getOccurrences()
Returns the occurrences array.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 start, int length)
Crops the existing result file and extracts a subset from the given starting point, with the given length.int
getResultSize()
Returns the effective size of the result set.double[]
getScores()
Returns the documents scores after retrievalint
getStatusCode()
get status codeboolean
hasMetaItems(java.lang.String name)
Unsupportedvoid
initialise()
This method initialises the arrays to be sorted, after the matching phase has been completedvoid
initialise(double[] scs)
Unsupportedvoid
setExactResultSize(int newExactResultSize)
Sets the exact size of the result set, that is the number of documents that contain at least one query term.void
setResultSize(int newResultSize)
Sets the effective size of the result set, that is the number of documents to be sorted after retrieval.void
setStatusCode(int _statusCode)
set status codevoid
sort()
Sorts all documents in this resultset by descending scorevoid
sort(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:
getStatusCode
in 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:
setStatusCode
in 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:
initialise
in interfaceResultSet
-
initialise
public void initialise(double[] scs)
Unsupported- Specified by:
initialise
in 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:
getResultSize
in interfaceResultSet
- Returns:
- int the effective size of the result set
-
getOccurrences
public short[] getOccurrences()
Returns the occurrences array.- Specified by:
getOccurrences
in interfaceResultSet
- Returns:
- short[] the array the occurrences array.
-
getExactResultSize
public int getExactResultSize()
Returns the exact size of the result set.- Specified by:
getExactResultSize
in 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:
setResultSize
in 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:
setExactResultSize
in interfaceResultSet
- Parameters:
newExactResultSize
- int the effective size of the result set.
-
sort
public void sort()
Description copied from interface:ResultSet
Sorts all documents in this resultset by descending score
-
sort
public void sort(int topDocs)
Description copied from interface:ResultSet
Sorts 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:
addMetaItem
in 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:
addMetaItems
in 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:
getMetaItem
in 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:
getMetaItems
in 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:
hasMetaItems
in interfaceResultSet
- Parameters:
name
- of the desired metaitem set- Returns:
- true if the set exists.
-
getMetaKeys
public java.lang.String[] getMetaKeys()
Unsupported- Specified by:
getMetaKeys
in interfaceResultSet
- Returns:
- the list of key names
-
allMetaItems
public java.lang.String[][] allMetaItems()
Unsupported- Specified by:
allMetaItems
in 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:
getResultSet
in 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:
getResultSet
in 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.
-
-