org.apache.lucene.benchmark.byTask.tasks

## Class ReadTask

- java.lang.Object
- - org.apache.lucene.benchmark.byTask.tasks.PerfTask
  - - org.apache.lucene.benchmark.byTask.tasks.ReadTask

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    SearchTask, SearchTravTask, SearchWithSortTask, WarmTask

      public abstract class ReadTask
      extends PerfTask

  Read index (abstract) task. Sub classes implement withSearch(), withWarm(), withTraverse() and withRetrieve() methods to configure the actual action.

  Note: All ReadTasks reuse the reader if it is already open. Otherwise a reader is opened at start and closed at the end.

  The `search.num.hits` config parameter sets the top number of hits to collect during searching.

  Other side effects: none.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.benchmark.byTask.tasks.PerfTask

      `logStep, NEW_LINE, params`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReadTask(PerfRunData runData)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `doLogic()` Perform the task once (ignoring repetitions specification) Return number of work items done by this task.
    `protected BenchmarkHighlighter` | `getBenchmarkHighlighter(Query q)` Return an appropriate highlighter to be used with highlighting tasks
    `protected java.util.Collection` | `getFieldsToHighlight(Document document)` Define the fields to highlight.
    `abstract QueryMaker` | `getQueryMaker()` Return query maker used for this task.
    `protected Sort` | `getSort()`
    `int` | `numHits()` Specify the number of hits to retrieve.
    `int` | `numToHighlight()` Set to the number of documents to highlight.
    `protected Document` | `retrieveDoc(IndexReader ir, int id)`
    `void` | `setup()` Task setup work that should not be measured for that specific task.
    `int` | `traversalSize()` Specify the number of hits to traverse.
    `boolean` | `withMaxScore()` Whether maxScores should be computed (only useful with field sort)
    `abstract boolean` | `withRetrieve()` Return true if, with search & results traversing, docs should be retrieved.
    `boolean` | `withScore()` Whether scores should be computed (only useful with field sort)
    `abstract boolean` | `withSearch()` Return true if search should be performed.
    `abstract boolean` | `withTraverse()` Return true if, with search, results should be traversed.
    `abstract boolean` | `withWarm()` Return true if warming should be performed.

    - ### Methods inherited from class org.apache.lucene.benchmark.byTask.tasks.PerfTask

      `clone, close, getDepth, getLogMessage, getName, getParams, getRunData, isDisableCounting, runAndMaybeStats, setDepth, setDisableCounting, setName, setParams, shouldNeverLogAtStart, shouldNotRecordStats, supportsParams, tearDown, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ReadTask

          public ReadTask(PerfRunData runData)

  - ### Method Detail

    - #### doLogic

          public int doLogic()
                      throws java.lang.Exception

      Description copied from class: `PerfTask`
      Perform the task once (ignoring repetitions specification) Return number of work items done by this task. For indexing that can be number of docs added. For warming that can be number of scanned items, etc.
      Specified by:
        `doLogic` in class `PerfTask`
      Returns:
        number of work items done by this task.
      Throws:
        `java.lang.Exception`

    - #### retrieveDoc

          protected Document retrieveDoc(IndexReader ir,
                                         int id)
                                  throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getQueryMaker

          public abstract QueryMaker getQueryMaker()

      Return query maker used for this task.

    - #### withSearch

          public abstract boolean withSearch()

      Return true if search should be performed.

    - #### withWarm

          public abstract boolean withWarm()

      Return true if warming should be performed.

    - #### withTraverse

          public abstract boolean withTraverse()

      Return true if, with search, results should be traversed.

    - #### withScore

          public boolean withScore()

      Whether scores should be computed (only useful with field sort)

    - #### withMaxScore

          public boolean withMaxScore()

      Whether maxScores should be computed (only useful with field sort)

    - #### traversalSize

          public int traversalSize()

      Specify the number of hits to traverse. Tasks should override this if they want to restrict the number of hits that are traversed when `withTraverse()` is true. Must be greater than 0.

      Read task calculates the traversal as: Math.min(hits.length(), traversalSize())
      Returns:
        Integer.MAX_VALUE

    - #### setup

          public void setup()
                     throws java.lang.Exception

      Description copied from class: `PerfTask`
      Task setup work that should not be measured for that specific task. By default it does nothing, but tasks can implement this, moving work from doLogic() to this method. Only the work done in doLogicis measured for this task. Notice that higher level (sequence) tasks containing this task would then measure larger time than the sum of their contained tasks.
      Overrides:
        `setup` in class `PerfTask`
      Throws:
        `java.lang.Exception`

    - #### numHits

          public int numHits()

      Specify the number of hits to retrieve. Tasks should override this if they want to restrict the number of hits that are collected during searching. Must be greater than 0.
      Returns:
        10 by default, or search.num.hits config if set.

    - #### withRetrieve

          public abstract boolean withRetrieve()

      Return true if, with search & results traversing, docs should be retrieved.

    - #### numToHighlight

          public int numToHighlight()

      Set to the number of documents to highlight.
      Returns:
        The number of the results to highlight. O means no docs will be highlighted.

    - #### getBenchmarkHighlighter

          protected BenchmarkHighlighter getBenchmarkHighlighter(Query q)

      Return an appropriate highlighter to be used with highlighting tasks

    - #### getSort

          protected Sort getSort()

    - #### getFieldsToHighlight

          protected java.util.Collection getFieldsToHighlight(Document document)

      Define the fields to highlight. Base implementation returns all fields
      Parameters:
        `document` - The Document
      Returns:
        A Collection of Field names (Strings)

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.