Class AbstractDataList<DATATYPE extends Data>

  • All Implemented Interfaces:
    com.yahoo.component.provider.Freezable, com.yahoo.component.provider.ListenableFreezable, Data, DataList<DATATYPE>, Ordered, Streamed
    Direct Known Subclasses:
    ArrayDataList

    public abstract class AbstractDataList<DATATYPE extends Data>
    extends com.yahoo.component.provider.ListenableFreezableClass
    implements DataList<DATATYPE>, Streamed, Ordered
    A convenience superclass for dataList implementations which handles references to the request and to incoming data.
    Author:
    bratseth
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> complete()
      Returns a future in which all incoming data in this has become available.
      IncomingData<DATATYPE> incoming()
      Returns the holder of incoming data to this.
      boolean isOrdered()
      Returns false if the data in this list can be returned in any order.
      boolean isStreamed()
      Returns false if the data in this list can not be returned until it is completed.
      Request request()
      Returns the request which created this data
      java.lang.String toString()  
      • Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass

        addFreezeListener, clone, freeze
      • Methods inherited from class com.yahoo.component.provider.FreezableClass

        ensureNotFrozen, isFrozen
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.yahoo.component.provider.Freezable

        freeze, isFrozen
      • Methods inherited from interface com.yahoo.component.provider.ListenableFreezable

        addFreezeListener
    • Constructor Detail

      • AbstractDataList

        protected AbstractDataList​(Request request)
        Creates a simple data list which does not allow late incoming data
        Parameters:
        request - the request which created this data list
      • AbstractDataList

        protected AbstractDataList​(Request request,
                                   IncomingData<DATATYPE> incomingData)
        Creates a simple data list which receives incoming data in the given instance
        Parameters:
        request - the request which created this data list, never null
        incomingData - the recipient of incoming data to this list, never null
      • AbstractDataList

        protected AbstractDataList​(Request request,
                                   IncomingData<DATATYPE> incomingData,
                                   boolean ordered,
                                   boolean streamed)
        Creates a simple data list which receives incoming data in the given instance
        Parameters:
        request - the request which created this data list, never null
        incomingData - the recipient of incoming data to this list, never null
    • Method Detail

      • request

        public Request request()
        Returns the request which created this data
        Specified by:
        request in interface Data
      • incoming

        public IncomingData<DATATYPE> incoming()
        Returns the holder of incoming data to this. This may be used to add, consume, wait for and be notified about incoming data. If this instance does not support late incoming data, the read methods of the return object behaves as expected and is synchronization free. The write methods throws an exception.
        Specified by:
        incoming in interface DataList<DATATYPE extends Data>
      • complete

        public com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> complete()
        Description copied from interface: DataList
        Returns a future in which all incoming data in this has become available. This has two uses:
        • Calling DataList.get(int) on this future will block (if necessary) until all incoming data has arrived, transfer that data from the incoming buffer into this list and invoke any listeners on this event on the calling thread.
        • Adding a listener on this future will cause it to be called when completion().get() is called, after the incoming data has been moved to this thread and before the get() call returns.

        Note that if no thread calls completed().get(), this future will never occur.

        Any data list consumer who wishes to make sure it sees the complete data for this list must call dataList.complete().get() before consuming this list. If a guaranteed non-blocking call to this method is desired, register a listener on the future where all data is available for draining (that is, on dataList.incoming().completed()) and resume by calling this method from the listener.

        Making this call on a list which does not support future data always returns immediately and causes no memory synchronization cost.

        Specified by:
        complete in interface DataList<DATATYPE extends Data>
      • isOrdered

        public boolean isOrdered()
        Description copied from interface: Ordered
        Returns false if the data in this list can be returned in any order. Default: true, meaning the order matters
        Specified by:
        isOrdered in interface Ordered
      • isStreamed

        public boolean isStreamed()
        Description copied from interface: Streamed
        Returns false if the data in this list can not be returned until it is completed. Default: true, meaning eager streaming of the data is permissible.
        Specified by:
        isStreamed in interface Streamed
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object