org.apache.lucene.benchmark.byTask.feeds

## Class ContentItemsSource

- java.lang.Object
- - org.apache.lucene.benchmark.byTask.feeds.ContentItemsSource

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    ContentSource, FacetSource

      public abstract class ContentItemsSource
      extends Object
      implements Closeable

  Base class for source of data for benchmarking

  Keeps track of various statistics, such as how many data items were generated, size in bytes etc.

  Supports the following configuration parameters:

  - content.source.forever - specifies whether to generate items forever (default=true).
  - content.source.verbose - specifies whether messages should be output by the content source (default=false).
  - content.source.encoding - specifies which encoding to use when reading the files of that content source. Certain implementations may define a default value if this parameter is not specified. (default=null).
  - content.source.log.step - specifies for how many items a message should be logged. If set to 0 it means no logging should occur. NOTE: if verbose is set to false, logging should not occur even if logStep is not 0 (default=0).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `encoding`
    `protected boolean` | `forever`
    `protected int` | `logStep`
    `protected boolean` | `verbose`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContentItemsSource()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addBytes(long numBytes)` update count of bytes generated by this source
    `protected void` | `addItem()` update count of items generated by this source
    `abstract void` | `close()` Called when reading from this content source is no longer required.
    `protected void` | `collectFiles(Path dir, ArrayList<Path> files)` A convenience method for collecting all the files of a content source from a given directory.
    `long` | `getBytesCount()` Returns the number of bytes generated since last reset.
    `Config` | `getConfig()`
    `int` | `getItemsCount()` Returns the number of generated items since last reset.
    `long` | `getTotalBytesCount()` Returns the total number of bytes that were generated by this source.
    `int` | `getTotalItemsCount()` Returns the total number of generated items.
    `void` | `printStatistics(String itemsName)`
    `void` | `resetInputs()` Resets the input for this content source, so that the test would behave as if it was just started, input-wise.
    `void` | `setConfig(Config config)` Sets the `Config` for this content source.
    `protected boolean` | `shouldLog()` Returns true whether it's time to log a message (depending on verbose and the number of items generated).

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

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

- - ### Field Detail

    - #### forever

          protected boolean forever

    - #### logStep

          protected int logStep

    - #### verbose

          protected boolean verbose

    - #### encoding

          protected String encoding

  - ### Constructor Detail

    - #### ContentItemsSource

          public ContentItemsSource()

  - ### Method Detail

    - #### addBytes

          protected final void addBytes(long numBytes)

      update count of bytes generated by this source

    - #### addItem

          protected final void addItem()

      update count of items generated by this source

    - #### collectFiles

          protected final void collectFiles(Path dir,
                                            ArrayList<Path> files)
                                     throws IOException

      A convenience method for collecting all the files of a content source from a given directory. The collected `Path` instances are stored in the given `files`.
      Throws:
        `IOException`

    - #### shouldLog

          protected final boolean shouldLog()

      Returns true whether it's time to log a message (depending on verbose and the number of items generated).

    - #### close

          public abstract void close()
                              throws IOException

      Called when reading from this content source is no longer required.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `IOException`

    - #### getBytesCount

          public final long getBytesCount()

      Returns the number of bytes generated since last reset.

    - #### getItemsCount

          public final int getItemsCount()

      Returns the number of generated items since last reset.

    - #### getConfig

          public final Config getConfig()

    - #### getTotalBytesCount

          public final long getTotalBytesCount()

      Returns the total number of bytes that were generated by this source.

    - #### getTotalItemsCount

          public final int getTotalItemsCount()

      Returns the total number of generated items.

    - #### resetInputs

          public void resetInputs()
                           throws IOException

      Resets the input for this content source, so that the test would behave as if it was just started, input-wise.

      NOTE: the default implementation resets the number of bytes and items generated since the last reset, so it's important to call super.resetInputs in case you override this method.

      Throws:
        `IOException`

    - #### setConfig

          public void setConfig(Config config)

      Sets the `Config` for this content source. If you override this method, you must call super.setConfig.

    - #### printStatistics

          public void printStatistics(String itemsName)

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