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