com.hazelcast.jet.pipeline

## Class SourceBuilder.Batch<T>

- java.lang.Object
- - com.hazelcast.jet.pipeline.SourceBuilder.Batch<T>

- Type Parameters:
    `T` -
  Enclosing class:
    SourceBuilder<S>

      public final class SourceBuilder.Batch<T>
      extends Object

  A builder of a batch stream source.
  See Also:
    `SourceBuilder.batch(String, DistributedFunction)`

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BatchSource<T>` | `build()` Builds and returns the batch source.
    `SourceBuilder.Batch<T>` | `destroyFn(DistributedConsumer<? super S> destroyFn)` Sets the function that Jet will call when cleaning up after a job has ended.
    `SourceBuilder.Batch<T>` | `distributed(int preferredLocalParallelism)` Declares that you're creating a distributed source.
    `<T_NEW> SourceBuilder.Batch<T_NEW>` | `fillBufferFn(DistributedBiConsumer<? super S,? super SourceBuilder.SourceBuffer<T_NEW>> fillBufferFn)` Sets the function that Jet will call whenever it needs more data from your source.

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

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

- - ### Method Detail

    - #### fillBufferFn

          @Nonnull
          public <T_NEW> SourceBuilder.Batch<T_NEW> fillBufferFn(@Nonnull
                                                                          DistributedBiConsumer<? super S,? super SourceBuilder.SourceBuffer<T_NEW>> fillBufferFn)

      Sets the function that Jet will call whenever it needs more data from your source. The function receives the state object obtained from `createFn` and Jet's buffer object. It should add some items to the buffer, ideally those it can produce without making any blocking calls. On any given invocation the function may also choose not to add any items. Jet will automatically employ an exponential backoff strategy to avoid calling your function in a tight loop during a period when there's no data ready to be emitted.

      Once it has emitted all the data, the function must call `SourceBuilder.SourceBuffer.close()`.

      Type Parameters:
        `T_NEW` - type of the emitted items
      Parameters:
        `fillBufferFn` - function that fills the buffer with source data
      Returns:
        this builder with the item type reset to the one inferred from `fillBufferFn`

    - #### destroyFn

          @Nonnull
          public SourceBuilder.Batch<T> destroyFn(@Nonnull
                                                           DistributedConsumer<? super S> destroyFn)

      Sets the function that Jet will call when cleaning up after a job has ended. It gives you the opportunity to release any resources held by the state object.

    - #### distributed

          @Nonnull
          public SourceBuilder.Batch<T> distributed(int preferredLocalParallelism)

      Declares that you're creating a distributed source. On each member of the cluster Jet will create as many processors as you specify with the `preferredLocalParallelism` parameter. If you call this, you must ensure that all the source processors are coordinated and not emitting duplicated data. The `createFn` can consult `procContext.totalParallelism()` and `procContext.globalProcessorIndex()`. Jet calls `createFn` exactly once with each `globalProcessorIndex` from 0 to `totalParallelism - 1`, this can help all the instances agree on which part of the data to emit.
      Parameters:
        `preferredLocalParallelism` - requested number of processors on each cluster member

    - #### build

          @Nonnull
          public BatchSource<T> build()

      Builds and returns the batch source.

Copyright © 2018. All rights reserved.