Interface Sink


public interface Sink

Accepts output tuples from a pipeline step, possibly for saving results, but also potentially for processing them before having them emerge somewhere else in the pipeline.

Some of this interface is coded for potential asynchronous I/O, but for now we're not respecting it (for the most part) and neither are we using it. But the idea is that in the future that instead of blocking, a Sink can refuse to accept more Tuples if some underlying buffer is full.

Note that a Sink doesn't extend AutoCloseable - finish has different semantics to close - finish means we've stopped writing to it, but it doesn't (necessarily) mean we're ready to do away with the sunk results. So for now at least they are separate.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Sink
    A sink that throws tuples away
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    accept(Tuple tuple)
    Pass a tuple to the sink to consume.
    default boolean
    If this sink is a bounded sink, then this method should return a best guess at whether accept will return true.
    void
    Tells the sink that there are no more tuples left to accept.
    default boolean
    If true, this sink will never return false from accept(Tuple)
  • Field Details

    • DEVNULL

      static final Sink DEVNULL

      A sink that throws tuples away

  • Method Details

    • accept

      boolean accept(Tuple tuple)

      Pass a tuple to the sink to consume.

      Returns:
      false if the sink is full and can not accept the tuple (right now)
    • finish

      void finish()

      Tells the sink that there are no more tuples left to accept.

    • isUnbounded

      default boolean isUnbounded()

      If true, this sink will never return false from accept(Tuple)

    • canAccept

      default boolean canAccept()

      If this sink is a bounded sink, then this method should return a best guess at whether accept will return true. Calling code should be prepared for canAccept to return true but then the call to accept will return false.