GeoTools
  1. GeoTools
  2. GEOT-2626

Improve StreamingRenderer handling of render events

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.7, 2.6-M1
    • Fix Version/s: 2.5.8, 2.6-M2
    • Component/s: render
    • Labels:
      None

      Description

      StreamingRenderer may hold one or more RenderListener that get notified of every feature rendered and any exception occurred while in the rendering loop.
      This way, StreamingRenderer defers the decision on when to stop rendering to client code, making for a best effort strategy to handle as much content as possible.

      The list of listeners is held in a CopyOnWriteArrayList for maximum performance, yet around a 10% of the time spent by the renderer is consumed by the fireFeatureRendered and fireErrorOcurred methods which can be saved if the list of listeners is not asked for an iterator but index based access is used instead, as per in the following patch:

      Index: StreamingRenderer.java
      ===================================================================
      --- StreamingRenderer.java	(revision 33604)
      +++ StreamingRenderer.java	(working copy)
      @@ -381,15 +381,23 @@
               if( !(feature instanceof SimpleFeature)){
                   return;
               }
      -		for(RenderListener listener : renderListeners) {
      -			listener.featureRenderer((SimpleFeature) feature);
      -		}
      +        if (renderListeners.size() > 0) {
      +            RenderListener listener;
      +            for (int i = 0; i < renderListeners.size(); i++) {
      +                listener = renderListeners.get(i);
      +                listener.featureRenderer((SimpleFeature) feature);
      +            }
      +        }
       	}
       
       	private void fireErrorEvent(Exception e) {
      -	    for(RenderListener listener : renderListeners) {
      -			listener.errorOccurred(e);
      -		}
      +        if (renderListeners.size() > 0) {
      +            RenderListener listener;
      +            for (int i = 0; i < renderListeners.size(); i++) {
      +                listener = renderListeners.get(i);
      +                listener.errorOccurred(e);
      +            }
      +        }
       	}
       
       	/**
      

        Issue Links

          Activity

          Hide
          Gabriel Roldan added a comment -
          fixed at r33605
          Show
          Gabriel Roldan added a comment - fixed at r33605
          Hide
          Gabriel Roldan added a comment -
          reopening to apply the same improvement to ShapefileRenderer
          Show
          Gabriel Roldan added a comment - reopening to apply the same improvement to ShapefileRenderer
          Hide
          Gabriel Roldan added a comment -
          StreamingRenderer fixed at r33606
          Show
          Gabriel Roldan added a comment - StreamingRenderer fixed at r33606
          Hide
          Gabriel Roldan added a comment -
          reopening in order to backport to 2.5.x
          Show
          Gabriel Roldan added a comment - reopening in order to backport to 2.5.x
          Hide
          Gabriel Roldan added a comment -
          ported to 2.5.x at r33814
          Show
          Gabriel Roldan added a comment - ported to 2.5.x at r33814

            People

            • Assignee:
              Gabriel Roldan
              Reporter:
              Gabriel Roldan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: