org.apache.lucene.benchmark.byTask.tasks

## Class PerfTask

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

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    AddDocTask, ClearStatsTask, CloseIndexTask, CloseReaderTask, CommitIndexTask, ConsumeContentSourceTask, CreateIndexTask, DeleteByPercentTask, DeleteDocTask, FlushReaderTask, NearRealtimeReaderTask, NewAnalyzerTask, NewRoundTask, OpenIndexTask, OpenReaderTask, OptimizeTask, PrintReaderTask, ReadTask, ReadTokensTask, ReopenReaderTask, ReportTask, ResetInputsTask, SetPropTask, TaskSequence, UpdateDocTask, WriteLineDocTask

      public abstract class PerfTask
      extends java.lang.Object
      implements java.lang.Cloneable

  An abstract task to be tested for performance.
  Every performance task extends this class, and provides its own `doLogic()` method, which performs the actual task.
  Tasks performing some work that should be measured for the task, can override `setup()` and/or `tearDown()` and place that work there.
  Relevant properties: `task.max.depth.log`.
  Also supports the following logging attributes:
  - log.step - specifies how often to log messages about the current running task. Default is 1000 `doLogic()` invocations. Set to -1 to disable logging.
  - log.step.[class Task Name] - specifies the same as 'log.step', only for a particular task name. For example, log.step.AddDoc will be applied only for `AddDocTask`, but not for `DeleteDocTask`. It's a way to control per task logging settings. If you want to omit logging for any other task, include log.step=-1. The syntax is "log.step." together with the Task's 'short' name (i.e., without the 'Task' part).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `logStep`
    `protected static java.lang.String` | `NEW_LINE`
    `protected java.lang.String` | `params`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PerfTask(PerfRunData runData)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.lang.Object` | `clone()`
    `void` | `close()`
    `abstract int` | `doLogic()` Perform the task once (ignoring repetitions specification) Return number of work items done by this task.
    `int` | `getDepth()`
    `protected java.lang.String` | `getLogMessage(int recsCount)`
    `java.lang.String` | `getName()`
    `java.lang.String` | `getParams()`
    `PerfRunData` | `getRunData()`
    `boolean` | `isDisableCounting()` Return true if counting is disabled for this task.
    `int` | `runAndMaybeStats(boolean reportStats)` Run the task, record statistics.
    `void` | `setDepth(int depth)`
    `void` | `setDisableCounting(boolean disableCounting)` See `isDisableCounting()`
    `protected void` | `setName(java.lang.String name)`
    `void` | `setParams(java.lang.String params)` Set the params of this task.
    `void` | `setup()` Task setup work that should not be measured for that specific task.
    `protected boolean` | `shouldNeverLogAtStart()` Tasks that should never log at start can override this.
    `protected boolean` | `shouldNotRecordStats()` Tasks that should not record statistics can override this.
    `boolean` | `supportsParams()` Sub classes that supports parameters must override this method to return true.
    `void` | `tearDown()` Task tearDown work that should not be measured for that specific task.
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### logStep

          protected int logStep

    - #### params

          protected java.lang.String params

    - #### NEW_LINE

          protected static final java.lang.String NEW_LINE

  - ### Constructor Detail

    - #### PerfTask

          public PerfTask(PerfRunData runData)

  - ### Method Detail

    - #### clone

          protected java.lang.Object clone()
                                    throws java.lang.CloneNotSupportedException

      Overrides:
        `clone` in class `java.lang.Object`
      Throws:
        `java.lang.CloneNotSupportedException`

    - #### close

          public void close()
                     throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### runAndMaybeStats

          public final int runAndMaybeStats(boolean reportStats)
                                     throws java.lang.Exception

      Run the task, record statistics.
      Returns:
        number of work items done by this task.
      Throws:
        `java.lang.Exception`

    - #### doLogic

          public abstract int doLogic()
                               throws java.lang.Exception

      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.
      Returns:
        number of work items done by this task.
      Throws:
        `java.lang.Exception`

    - #### getName

          public java.lang.String getName()

      Returns:
        Returns the name.

    - #### setName

          protected void setName(java.lang.String name)

      Parameters:
        `name` - The name to set.

    - #### getRunData

          public PerfRunData getRunData()

      Returns:
        Returns the run data.

    - #### getDepth

          public int getDepth()

      Returns:
        Returns the depth.

    - #### setDepth

          public void setDepth(int depth)

      Parameters:
        `depth` - The depth to set.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getLogMessage

          protected java.lang.String getLogMessage(int recsCount)

    - #### shouldNeverLogAtStart

          protected boolean shouldNeverLogAtStart()

      Tasks that should never log at start can override this.
      Returns:
        true if this task should never log when it start.

    - #### shouldNotRecordStats

          protected boolean shouldNotRecordStats()

      Tasks that should not record statistics can override this.
      Returns:
        true if this task should never record its statistics.

    - #### setup

          public void setup()
                     throws java.lang.Exception

      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.
      Throws:
        `java.lang.Exception`

    - #### tearDown

          public void tearDown()
                        throws java.lang.Exception

      Task tearDown 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.
      Throws:
        `java.lang.Exception`

    - #### supportsParams

          public boolean supportsParams()

      Sub classes that supports parameters must override this method to return true.
      Returns:
        true iff this task supports command line params.

    - #### setParams

          public void setParams(java.lang.String params)

      Set the params of this task.
      Throws:
        `java.lang.UnsupportedOperationException` - for tasks supporting command line parameters.

    - #### getParams

          public java.lang.String getParams()

      Returns:
        Returns the Params.

    - #### isDisableCounting

          public boolean isDisableCounting()

      Return true if counting is disabled for this task.

    - #### setDisableCounting

          public void setDisableCounting(boolean disableCounting)

      See `isDisableCounting()`

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