Class Buffer<K extends Comparable<K>>

java.lang.Object
io.aiven.commons.kafka.connector.source.lookback.Buffer<K>
Type Parameters:
K - the key type.
All Implemented Interfaces:
Lookback<K>

public class Buffer<K extends Comparable<K>> extends Object implements Lookback<K>
Lookback that uses a buffer to track the last N records.
  • Method Details

    • add

      public void add(K key)
      Description copied from interface: Lookback
      Adds a key to the lookback tracking.
      Specified by:
      add in interface Lookback<K extends Comparable<K>>
      Parameters:
      key - the key to add.
    • get

      public K get()
      Description copied from interface: Lookback
      Gets the key to query for.
      Specified by:
      get in interface Lookback<K extends Comparable<K>>
      Returns:
      the key to query for.
    • contains

      public boolean contains(K key)
      Description copied from interface: Lookback
      Determines if the key is in the lookback.
      Specified by:
      contains in interface Lookback<K extends Comparable<K>>
      Parameters:
      key - the key to search for.
      Returns:
      true if this lookback holds the key.
    • size

      public int size()
      Description copied from interface: Lookback
      Gets the number of keys this Lookback can store.
      Specified by:
      size in interface Lookback<K extends Comparable<K>>
      Returns:
      the number of keys this Lookback can store.
    • resize

      public Lookback<K> resize(int size)
      Description copied from interface: Lookback
      Resize the lookback. May resize this lookback or create new one. The resulting lookback will contain as much of the latest data from this lookback as possible in the new configuration.
      Specified by:
      resize in interface Lookback<K extends Comparable<K>>
      Parameters:
      size - the desired size of the lookback. If size < 0 then 0 is used.
      Returns:
      a Lookback instance of the desired size.