Class BulkingSink<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    AutoCloseable, Sink<T>

    public class BulkingSink<T>
    extends Object
    implements Sink<T>
    A sink that collects items in a buffer. Only when the buffer becomes full OR flush is called manually then items are flushed to the delegate in bulk. Closing does not flush pending items! This class is not thread-safe.
    Author:
    raven
    • Field Detail

      • buffer

        protected T[] buffer
      • nextOffsetInBuffer

        protected int nextOffsetInBuffer
      • isClosed

        protected boolean isClosed
    • Constructor Detail

      • BulkingSink

        public BulkingSink​(int bulkSize,
                           BulkConsumer delegate)
    • Method Detail

      • ensureOpen

        protected void ensureOpen()
      • accept

        public void accept​(T item)
        Specified by:
        accept in interface Sink<T>
      • flush

        public void flush()
        Specified by:
        flush in interface Sink<T>
      • flushActual

        protected void flushActual()