Hi, as you suggest, at the moment my strategy is to sort the result
afterwards and then to filter the required page.
However, if I have some time I would like to implement sorting in the JDBC
optimized visitor. In this way I would need to discriminate depending on
the data source, but performance will be much better on JDBC databases.

Regards,

César


2014-04-22 9:37 GMT+02:00 Jody Garnett <jody.garn...@gmail.com>:

> Looking at the internals of UniqueVisitor is uses:
>
> Set set = new HashSet();
>
> Can you sort this result yourself after calling the visitor? Or would you
> like to submit a patch to use TreeSet?
>
> Jody Garnett
>
>
> On Thu, Apr 17, 2014 at 7:42 PM, 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?
>>
>> Thanks in advance,
>>
>> César
>>
>> [1]
>> http://osgeo-org.1560.x6.nabble.com/distinct-query-hint-td5049204.html
>>
>> --
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>    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
>>
>>
>


-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   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)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to