java.lang.Object
org.apache.flink.connector.file.src.util.Pool<T>
Type Parameters:
T - The type of object cached in the pool.

@PublicEvolving public class Pool<T> extends Object
A pool to cache and recycle heavyweight objects, to reduce object allocation.

This pool can be used in the BulkFormat.Reader, when the returned objects are heavyweight and need to be reused for efficiency. Because the reading happens in I/O threads while the record processing happens in Flink's main processing threads, these objects cannot be reused immediately after being returned. They can be reused, once they are recycled back to the pool.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A Recycler puts objects into the pool that the recycler is associated with.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pool(int poolCapacity)
    Creates a pool with the given capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T object)
    Adds an entry to the pool with an optional payload.
    Gets the next cached entry.
    Gets the recycler for this pool.
    Tries to get the next cached entry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Pool

      public Pool(int poolCapacity)
      Creates a pool with the given capacity. No more than that many elements may be added to the pool.
  • Method Details

    • recycler

      public Pool.Recycler<T> recycler()
      Gets the recycler for this pool. The recycler returns its given objects back to this pool.
    • add

      public void add(T object)
      Adds an entry to the pool with an optional payload. This method fails if called more often than the pool capacity specified during construction.
    • pollEntry

      public T pollEntry() throws InterruptedException
      Gets the next cached entry. This blocks until the next entry is available.
      Throws:
      InterruptedException
    • tryPollEntry

      @Nullable public T tryPollEntry()
      Tries to get the next cached entry. If the pool is empty, this method returns null.