Thanks Andrea for the pointer,
Those improvements on JDBCDataStore do not seem complicated, but then the
code I wrote will behave inconsistently depending on the underlying data
source (well, maybe it is inconsistent also with current implementation).
My current approach to get consistent is to sort and page the result after
applying the visitor, thus skipping any database improvements for sorting
and merging.
Any other suggestion?
César
2014-04-17 11:56 GMT+02:00 Andrea Aime <andrea.a...@geo-solutions.it>:
> On Thu, Apr 17, 2014 at 11:42 AM, César Martínez Izquierdo <
> cesar....@gmail.com> wrote:
>
>> Hello,
>>
>> I am trying to run a distinct values query, which should be at the same
>> time sorted and paged (offset and limit). I have tried the following code
>> (simplified):
>>
>> Query query = new Query(typeName, Filter.INCLUDE, new String[]
>> {fieldName});
>> query.setSortBy(new SortBy[]{sortBy});
>> query.setStartIndex(startIndex);
>> query.setMaxFeatures(maxFeatures);
>> SimpleFeatureCollection featCol = featureSource.getFeatures(query);
>> Expression expr = factory.property(fieldName);
>> UniqueVisitor visitor = new UniqueVisitor(expr);
>> featCol.accepts(visitor, null);
>>
>> I have have correctly understood the documentation, the feature
>> collection is not changed by the visitor, but I can get the result by using:
>> List uniqueValues = visitor.getResult().toList();
>> However, this result is not ordered, thus making impossible to run
>> queries such as:
>> SELECT DISTINCT(name) FROM osmadmlv2
>> ORDER BY name asc OFFSET 50 LIMIT 10
>>
>> I found a previous conversation [1] suggesting to implement DISTINCT it
>> as a Hint, but that case could be solved by using the visitor (but I guess
>> they did not need sorting and paging).
>>
>> Is not possible to do such query, am I doing something wrong or is it a
>> bug in the implementation?
>>
>
> I believe the current visitor sql translation in in JDBCDataoStore could
> be improved to take into account sorting.
> Paging seems to be already in there, by looking at the code
> in doSelectAggregateSQL
>
> Cheers
> Andrea
>
>
> --
> ==
> Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
> for more information.
> ==
>
> Ing. Andrea Aime
> @geowolf
> Technical Lead
>
> GeoSolutions S.A.S.
> Via Poggio alle Viti 1187
> 55054 Massarosa (LU)
> Italy
> phone: +39 0584 962313
> fax: +39 0584 1660272
> mob: +39 339 8844549
>
> http://www.geo-solutions.it
> http://twitter.com/geosolutions_it
>
> -------------------------------------------------------
>
--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
César Martínez Izquierdo
GIS developer
- - - - - - - - - - - - - - - - - - - -
Blog: http://geotechnotes.wordpress.com/
ETC-SIA: http://sia.eionet.europa.eu/
Universitat Autònoma de Barcelona (SPAIN)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users