Class SimpleBatchCreator<RequestEntryT extends Serializable>

  • Type Parameters:
    RequestEntryT - the type of request entries managed by this batch creator
    All Implemented Interfaces:
    BatchCreator<RequestEntryT>

    @Internal
    public class SimpleBatchCreator<RequestEntryT extends Serializable>
    extends Object
    implements BatchCreator<RequestEntryT>
    A simple implementation of BatchCreator that forms a batch by taking up to requestInfo.getBatchSize() entries from the head of the buffer, so long as the cumulative size in bytes does not exceed the configured maximum.

    This strategy stops gathering entries from the buffer as soon as adding the next entry would exceed the maxBatchSizeInBytes, or once it has collected requestInfo.getBatchSize() entries, whichever occurs first.

    • Constructor Detail

      • SimpleBatchCreator

        public SimpleBatchCreator​(long maxBatchSizeInBytes)
        Constructs a SimpleBatchCreator with the specified maximum batch size in bytes.
        Parameters:
        maxBatchSizeInBytes - the maximum cumulative size in bytes allowed for any single batch
    • Method Detail

      • createNextBatch

        public Batch<RequestEntryT> createNextBatch​(RequestInfo requestInfo,
                                                    RequestBuffer<RequestEntryT> bufferedRequestEntries)
        Creates the next batch of request entries based on the provided requestInfo and the currently buffered entries.
        Specified by:
        createNextBatch in interface BatchCreator<RequestEntryT extends Serializable>
        Parameters:
        requestInfo - information about the desired request properties or constraints (e.g., an allowed batch size or other relevant hints)
        bufferedRequestEntries - a collection ex: Deque of all currently buffered entries waiting to be grouped into batches
        Returns:
        a Batch containing the new batch of entries along with metadata about the batch (e.g., total byte size, record count)