Yes, the point is to capture the provided predicate, and if it is one of
our Filter objects we can pass it to the featureSource. Note this is a
Filter object, since it is an object oriented language. Any given datastore
is welcome to transform that into its own internal format for fun and
profit, SQL, CQL, ECQL, etc...

Internally I expect the stream implementation to stage a normal geotools
query and:
- use the filter as normal to request the contents, followed by the
existing visitor method to handle traversal when implementing the forEach
method.
- method such anyMatch( predicate ) can be handled quite well with a Query
with max features set to 1
- etc...

The sad part / danger / risk is that that our Filter interface would only
be one kind of predicate, and I would expect normal java developers to make
a query quickly in java code - which is something we cannot optimize.

--
Jody Garnett

On 5 August 2016 at 20:20, Jim Hughes <jn...@ccri.com> wrote:

> Hi Devon, Jody,
>
> This looks exciting!  For the (E)CQL filters as predicates, is there any
> chance those predicates could be passed down to the FeatureSource?  Or
> would there be different execution from...
>
> featureSource.stream.filter(predicate)....
> and
> featureSource.getFeatures(predicate).stream....
>
> Naively, it seems what you suggested (and my first example) would stream
> back all the features and then apply all filtering 'client' side.  If there
> are tricks to write the first and have it perform database queries
> sensibly, that might be good.
>
> If that support is only partial or is intuitive, I'd worry that we are
> giving folks a way to cause too much trouble.  On the other hand, if there
> are really clever options for pushing around computation, weaving that
> through the FeatureSource/Collection API could be really powerful.
>
> Cheers,
>
> Jim
>
>
> On 8/5/2016 7:07 PM, Jody Garnett wrote:
>
> Reviewing the methods with Devon a lot of it looked pretty straight
> forward using FeatureSource and visitor.
>
> featureSource.stream().forEach(
>    f -> System.out.println( f.getId() ) );
> );
>
> Once concern I had, well Kevin had, was how to handle predicates cleanly.
> There is an overlap of functionality between Predicates and our Filter
> interface - it would be great Filter could implement Predicate (allowing
> them to be used for java streams) and allowing us to detect the use of:
>
> Filter predicate = CQL.toFilter("attName >= 5");
>
> boolean found = featureSource.stream().anyMatch( predicate );
>
> featureSource.stream().filter( predicate ).forEach(
>    f -> System.out.println( f.getId() ) );
> );
>
> Collection<Geometry> geoms = featureSource.stream().map(
>     f -> (Geometry) f.getDefaultGeometry();
> ).collect( Collectors.toList() );
>
>
>
> --
> Jody Garnett
>
> On 5 August 2016 at 14:45, Devon Tucker <devonrtuc...@gmail.com> wrote:
>
>> Hi all,
>>
>> Jody and I were talking today about and idea he has been agitating for a
>> while. We'd like to basically implement the Java 8 streaming interface for
>> features on top of FeatureSource or FeatureCollection. Just throwing this
>> out there for early feedback to see what people think.
>>
>> Jody thinks that much of that API can be implemented in terms of the
>> existing functionality fairly simply/efficiently while others can be
>> delegated to simpler Stream objects (created from builder utilities).
>>
>> Interested in what people think. We'll probably do a quick proposal
>> shortly.
>>
>> Cheers,
>> Devon
>>
>> ------------------------------------------------------------
>> ------------------
>>
>> _______________________________________________
>> GeoTools-Devel mailing list
>> GeoTools-Devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>
>>
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> GeoTools-Devel mailing 
> listGeoTools-Devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>
------------------------------------------------------------------------------
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to