GeoTools
  1. GeoTools
  2. GEOT-3302

App-schema: get numberOfFeatures without executing the query

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: xml
    • Labels:
      None

      Description

      To support streaming of features, GeoServer WFS writes the root element of a response and then each feature as it is created. The root element requires a numberOfFeatures element; because the number of features is not known, GeoServer must get them all to count them. It then must get them all a second time to encode them one by one. (Streaming is needed as not all responses will fit in memory.) The consequence of the double query is that WFS responses take twice as long. This is particularly bad for app-schema as it is already very slow.

      In practice, GeoServer streams features to disk first, so that an error document can be returned if an error occurs. (This is a selectable output strategy.)

      In theory it should be possible to stream only the features to disk as an XML fragment, then encode the root element on the fly when all the features have been seen, meaning the numberOfFeatures is known, and only one query is required.

      This may require modification to Encoder, OutputStrategy, and OutputFormat APIs.

        Activity

        Hide
        Victor Tey added a comment -
        Committed in branch and trunk
        Show
        Victor Tey added a comment - Committed in branch and trunk
        Hide
        Victor Tey added a comment -
        Due to the error below, I need your approval for this patch for trunk and branch.

        SecuredFeatureCollection.features() is supposed to return a FeatureIterator but due to some policy setting on the server, it seem to return a Iterator instead. I was unable to replicate the issue on my local machine and it is machine setting specific.

        I was also unable to get any response from Andrea with regards to this therefore had to submit this workaround.

        2011-02-24 11:04:02,941 ERROR [geoserver.ows] -
        java.lang.ClassCastException: org.geoserver.security.decorators.SecuredIterator cannot be cast to org.geotools.feature.FeatureIterator
                at org.geoserver.security.decorators.SecuredFeatureCollection.features(SecuredFeatureCollection.java:57)
                at org.geoserver.wfs.response.HitsOutputFormat.countFeature(HitsOutputFormat.java:102)
                at org.geoserver.wfs.response.HitsOutputFormat.write(HitsOutputFormat.java:85)
                at org.geoserver.ows.Dispatcher.response(Dispatcher.java:751)
                at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:233)
                at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
                at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
                at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
                at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
                at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        Show
        Victor Tey added a comment - Due to the error below, I need your approval for this patch for trunk and branch. SecuredFeatureCollection.features() is supposed to return a FeatureIterator but due to some policy setting on the server, it seem to return a Iterator instead. I was unable to replicate the issue on my local machine and it is machine setting specific. I was also unable to get any response from Andrea with regards to this therefore had to submit this workaround. 2011-02-24 11:04:02,941 ERROR [geoserver.ows] - java.lang.ClassCastException: org.geoserver.security.decorators.SecuredIterator cannot be cast to org.geotools.feature.FeatureIterator         at org.geoserver.security.decorators.SecuredFeatureCollection.features(SecuredFeatureCollection.java:57)         at org.geoserver.wfs.response.HitsOutputFormat.countFeature(HitsOutputFormat.java:102)         at org.geoserver.wfs.response.HitsOutputFormat.write(HitsOutputFormat.java:85)         at org.geoserver.ows.Dispatcher.response(Dispatcher.java:751)         at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:233)         at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)         at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)         at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)         at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)         at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        Hide
        Justin Deoliveira added a comment -
        This patch is a bandaid... the real problem is in the security system so we should fix it there.

        I believe what is happening in this case is that there are iterator objects that implement both FeatureIterator and Iterator. So the security wrapper is wrapping it in this case as an Iterator when it should be wrapping it as a FeatureIterator. I am not sure exactly which iterator is doing this but one such iterator is ForceCoordinateSystemIterator.

        Not sure exactly what the best way to solve that issue is... perhaps passing in the interface into SecuredObjects.secure rather than just the object. Or perhaps just hunt down feature iterators that implement both and separate them out.I think the former is a more robust solution. Would like to hear Andrea weigh in on this one.
        Show
        Justin Deoliveira added a comment - This patch is a bandaid... the real problem is in the security system so we should fix it there. I believe what is happening in this case is that there are iterator objects that implement both FeatureIterator and Iterator. So the security wrapper is wrapping it in this case as an Iterator when it should be wrapping it as a FeatureIterator. I am not sure exactly which iterator is doing this but one such iterator is ForceCoordinateSystemIterator. Not sure exactly what the best way to solve that issue is... perhaps passing in the interface into SecuredObjects.secure rather than just the object. Or perhaps just hunt down feature iterators that implement both and separate them out.I think the former is a more robust solution. Would like to hear Andrea weigh in on this one.
        Hide
        Victor Tey added a comment -
        the only outstanding issue is with resultType=hits ClassCastException. I will create a seperate jira issue for that as it is not related
        Show
        Victor Tey added a comment - the only outstanding issue is with resultType=hits ClassCastException. I will create a seperate jira issue for that as it is not related
        Hide
        Andrea Aime added a comment -
        Mass closing all issues that have been in "resolved" state for more than one month without further comments
        Show
        Andrea Aime added a comment - Mass closing all issues that have been in "resolved" state for more than one month without further comments

          People

          • Assignee:
            Victor Tey
            Reporter:
            Rini Angreani
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: