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
    occurrences
    gnu.trove.TIntShortHashMap occurrencesMap
    occurrence map
    protected int resultSize  
    double[] scores
    scores[]
    gnu.trove.TIntDoubleHashMap scoresMap
    score map
    protected int statusCode  
  • Constructor Summary

    Constructors 
    Constructor Description
    AccumulatorResultSet​(int numberOfDocuments)
    Constructs an instance of the AccumulatorResultSet
  • Method Summary

    Modifier and Type Method Description
    void addMetaItem​(java.lang.String name, int docid, java.lang.String value)
    Unsupported
    void addMetaItems​(java.lang.String name, java.lang.String[] values)
    Unsupported
    java.lang.String[][] allMetaItems()
    Unsupported
    AccumulatorResultSet getAccumulatorResultSet​(int start, int length)  
    int[] getDocids()
    Returns the documents ids after retrieval
    int getExactResultSize()
    Returns the exact size of the result set.
    java.util.concurrent.locks.Lock getLock()
    get lock
    java.lang.String getMetaItem​(java.lang.String name, int docid)
    Unsupported
    java.lang.String[] getMetaItems​(java.lang.String name)
    Unsupported
    java.lang.String[] getMetaKeys()
    Unsupported
    short[] 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 retrieval
    int getStatusCode()
    get status code
    boolean hasMetaItems​(java.lang.String name)
    Unsupported
    void initialise()
    This method initialises the arrays to be sorted, after the matching phase has been completed
    void initialise​(double[] scs)
    Unsupported
    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.
    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 code
    void sort()
    Sorts all documents in this resultset by descending score
    void sort​(int topDocs)
    Sorts the top topDocs document in this resultset be first.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AccumulatorResultSet

      public AccumulatorResultSet​(int numberOfDocuments)
      Constructs an instance of the AccumulatorResultSet
      Parameters:
      numberOfDocuments - maximum size of the result set.
  • Method Details

    • getLock

      public java.util.concurrent.locks.Lock getLock()
      get lock
      Specified by:
      getLock in interface ResultSet
      Returns:
      the lock.
    • getStatusCode

      public int getStatusCode()
      get status code
      Specified by:
      getStatusCode in interface ResultSet
      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 interface ResultSet
      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 interface ResultSet
    • initialise

      public void initialise​(double[] scs)
      Unsupported
      Specified by:
      initialise in interface ResultSet
      Parameters:
      scs - double[] the scores to initiliase the result set with.
    • getDocids

      public int[] getDocids()
      Returns the documents ids after retrieval
      Specified by:
      getDocids in interface ResultSet
      Returns:
      the docids
    • getResultSize

      public int getResultSize()
      Returns the effective size of the result set.
      Specified by:
      getResultSize in interface ResultSet
      Returns:
      int the effective size of the result set
    • getOccurrences

      public short[] getOccurrences()
      Returns the occurrences array.
      Specified by:
      getOccurrences in interface ResultSet
      Returns:
      short[] the array the occurrences array.
    • getExactResultSize

      public int getExactResultSize()
      Returns the exact size of the result set.
      Specified by:
      getExactResultSize in interface ResultSet
      Returns:
      int the exact size of the result set
    • getScores

      public double[] getScores()
      Returns the documents scores after retrieval
      Specified by:
      getScores in interface ResultSet
      Returns:
      score list in same order as docids array
    • 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 interface ResultSet
      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 interface ResultSet
      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
      Specified by:
      sort in interface ResultSet
    • 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.
      Specified by:
      sort in interface ResultSet
      Parameters:
      topDocs - number of documents to top-rank
    • addMetaItem

      public void addMetaItem​(java.lang.String name, int docid, java.lang.String value)
      Unsupported
      Specified by:
      addMetaItem in interface ResultSet
      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 interface ResultSet
      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 interface ResultSet
      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 interface ResultSet
      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 interface ResultSet
      Parameters:
      name - of the desired metaitem set
      Returns:
      true if the set exists.
    • getMetaKeys

      public java.lang.String[] getMetaKeys()
      Unsupported
      Specified by:
      getMetaKeys in interface ResultSet
      Returns:
      the list of key names
    • allMetaItems

      public java.lang.String[][] allMetaItems()
      Unsupported
      Specified by:
      allMetaItems in interface ResultSet
    • 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 interface ResultSet
      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 interface ResultSet
      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 offset
      length - the number of results to keep
      See Also:
      Returns a ResultSet starting at the pre-determined position, of the specified size.