class_docstr: Generates output blocks of a given size given a stream of inputs.
  
  This class is used to turn a stream of items / blocks of arbitrary size
  into a stream of blocks of ``target_max_block_size``. The caller should
  check ``has_next()`` after each ``add()`` call, and call ``next()`` to get
  the next block when ``has_next()`` returns True.
  
  When all items have been added, the caller must call ``finalize()`` and
  then check ``has_next()`` one last time.
  
  Examples:
      >>> from ray.data._internal.output_buffer import BlockOutputBuffer
      >>> udf = ... # doctest: +SKIP
      >>> generator = ... # doctest: +SKIP
      >>> # Yield a stream of output blocks.
      >>> output = BlockOutputBuffer(udf, 500 * 1024 * 1024) # doctest: +SKIP
      >>> for item in generator(): # doctest: +SKIP
      ...     output.add(item) # doctest: +SKIP
      ...     if output.has_next(): # doctest: +SKIP
      ...         yield output.next() # doctest: +SKIP
      >>> output.finalize() # doctest: +SKIP
      >>> if output.has_next() # doctest: +SKIP
      ...     yield output.next() # doctest: +SKIP
docstr: Add a single item to this output buffer.
code: def add(self, item: Any) -> None:
      """Add a single item to this output buffer."""
      assert not self._finalized
      self._buffer.add(item)
  
file_path: ray/python/ray/data/_internal/output_buffer.py
imports: from typing import Any
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
  from ray.data.block import Block, BlockAccessor, DataBatch
  from ray.data.context import MAX_SAFE_BLOCK_SIZE_FACTOR
label_desc: Use image node_id 2 for calling the BlockOutputBuffer obj's underlying member method code with example usage: obj.add(item) without return types