From 06371345a7b7f7d27406bd8d72ca6769b7edb651 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Apr 2018 15:26:18 +0200 Subject: Clear renderer hit groups This allows us to stream more data than can fit in the container (across all concurrent queries), as rendered hits in completed groups can now be garbage collected. We can not deference the hit groups themselves as that entails modifying the parent list. --- .../com/yahoo/processing/response/DataList.java | 21 +++++++++++++++------ .../yahoo/processing/response/IncomingData.java | 22 +++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) (limited to 'processing/src') diff --git a/processing/src/main/java/com/yahoo/processing/response/DataList.java b/processing/src/main/java/com/yahoo/processing/response/DataList.java index 911cb6f70e6..1f762ab8d58 100644 --- a/processing/src/main/java/com/yahoo/processing/response/DataList.java +++ b/processing/src/main/java/com/yahoo/processing/response/DataList.java @@ -28,9 +28,9 @@ public interface DataList extends Data { * @param data the data to add to this * @return the input data instance, for chaining */ - public DATATYPE add(DATATYPE data); + DATATYPE add(DATATYPE data); - public DATATYPE get(int index); + DATATYPE get(int index); /** * Returns the content of this as a List. @@ -38,7 +38,7 @@ public interface DataList extends Data { * If the returned list is editable and this is frozen, the only allowed operation is to add new items * to the end of the list. */ - public List asList(); + List asList(); /** * Returns the buffer of incoming/future data to this list. @@ -49,7 +49,7 @@ public interface DataList extends Data { * such lists responds to read calls to IncomingData as expected and without * incurring any synchronization, and throws an exception on write calls. */ - public IncomingData incoming(); + IncomingData incoming(); /** * Returns a future in which all incoming data in this has become available. @@ -73,13 +73,22 @@ public interface DataList extends Data { * Making this call on a list which does not support future data always returns immediately and * causes no memory synchronization cost. */ - public ListenableFuture> complete(); + ListenableFuture> complete(); /** * Adds a listener which is invoked every time data is added to this list. * The listener is always invoked on the same thread which is adding the data, * and hence it can modify this list freely without synchronization. */ - public void addDataListener(Runnable runnable); + void addDataListener(Runnable runnable); + + /** + * Notify this list that is will never be accessed again, neither for read nor write. + * Implementations can override this as an optimization to release any data held in the list + * for garbage collection. + * + * This default implementation does nothing. + */ + default void close() {}; } diff --git a/processing/src/main/java/com/yahoo/processing/response/IncomingData.java b/processing/src/main/java/com/yahoo/processing/response/IncomingData.java index 7034b2c2a02..b8cdf8683bc 100644 --- a/processing/src/main/java/com/yahoo/processing/response/IncomingData.java +++ b/processing/src/main/java/com/yahoo/processing/response/IncomingData.java @@ -22,7 +22,7 @@ public interface IncomingData { * Note that accessing the owner from the thread producing incoming data * is generally *not* thread safe. */ - public DataList getOwner(); + DataList getOwner(); /** * Returns a future in which all the incoming data that will be produced in this is available. @@ -35,57 +35,57 @@ public interface IncomingData { *

* This return the list owning this for convenience. */ - public abstract ListenableFuture> completed(); + ListenableFuture> completed(); /** * Returns whether this is complete */ - public boolean isComplete(); + boolean isComplete(); /** * Add new data and mark this as completed * * @throws IllegalStateException if this is already complete or does not allow writes */ - public void addLast(DATATYPE data); + void addLast(DATATYPE data); /** * Add new data without completing this * * @throws IllegalStateException if this is already complete or does not allow writes */ - public void add(DATATYPE data); + void add(DATATYPE data); /** * Add new data and mark this as completed * * @throws IllegalStateException if this is already complete or does not allow writes */ - public void addLast(List data); + void addLast(List data); /** * Add new data without completing this. * * @throws IllegalStateException if this is already complete or does not allow writes */ - public void add(List data); + void add(List data); /** * Mark this as completed and notify any listeners. If this is already complete this method does nothing. */ - public void markComplete(); + void markComplete(); /** * Get and remove all the data currently available in this */ - public List drain(); + List drain(); /** * Add a listener which will be invoked every time new data is added to this. * This listener may be invoked at any time in any thread, any thread synchronization is left * to the listener itself */ - public void addNewDataListener(Runnable listener, Executor executor); + void addNewDataListener(Runnable listener, Executor executor); /** * Creates a null implementation of this which is empty and complete at creation: @@ -98,7 +98,7 @@ public interface IncomingData { * This allows consumers to check for completion the same way whether or not the data list in question * supports asynchronous addition of data, and without incurring unnecessary costs. */ - public static final class NullIncomingData implements IncomingData { + final class NullIncomingData implements IncomingData { private DataList owner; private final ImmediateFuture completionFuture; -- cgit v1.2.3