query.setMaxFeatures(Query.DEFAULT_MAX); } else { sortBy = null; query.setMaxFeatures(Query.DEFAULT_MAX);
FF.literal(range.getMaxValue())); query.setFilter(rangeFilter); query.setMaxFeatures(maxEntries); query.setPropertyNames(new String[] {descriptor.getStartAttribute()}); query.setHints(new Hints(StructuredCoverageViewReader.QUERY_FIRST_BAND, true));
/** * Builds next query for execute in data source * * @return */ private Query getNextSourceQuery() { Query nextQuery = new Query(query); Filter idInFilter = IndexQueryUtils.buildIdInExpression(getNextSourceIdList(), mapping); nextQuery.setFilter(idInFilter); nextQuery.setStartIndex(0); nextQuery.setMaxFeatures(Integer.MAX_VALUE); return nextQuery; }
@Override public int removeGranules(Filter filter, Hints hints) { try { int removed = catalog.removeGranules(new Query(typeName, filter)); // we cannot re-initialize a raster manager if there are no granules Query q = new Query(manager.getTypeName()); q.setMaxFeatures(1); if (DataUtilities.count(catalog.getGranules(q)) > 0) { manager.initialize(true); } return removed; } catch (IOException e) { throw new RuntimeException("Failed to remove granules matching " + filter, e); } }
private Query queryWithLimits(int lower, int upper) { Query query = new Query(tname("buildings")); query.setStartIndex(lower); query.setMaxFeatures(upper); return query; }
private Query namedQuery(Filter filter, int countLimit, boolean isJoining, Hints hints) { Query query = isJoining ? new JoiningQuery() : new Query(); if (getName().getNamespaceURI() != null) { try { query.setNamespace(new URI(getName().getNamespaceURI())); } catch (URISyntaxException e) { throw new RuntimeException(e); } } query.setTypeName(getName().getLocalPart()); query.setFilter(filter); query.setMaxFeatures(countLimit); query.setHints(hints); return query; }
public void testCountWithOffsetLimit() throws Exception { Query query = new Query(); query.setStartIndex(1); query.setMaxFeatures(1); assertEquals(1, featureSource.getCount(query)); }
/** Test of getMaxFeatures method, of class org.geotools.data.Query. */ public void testMaxFeatures() { // System.out.println("testMaxFeatures"); Query query = new Query(); assertEquals(Query.DEFAULT_MAX, query.getMaxFeatures()); query.setMaxFeatures(5); assertEquals(5, query.getMaxFeatures()); }
public void testPaginationWithPlaceHolder() throws Exception { Query query = new Query("riverFullPlaceHolder"); query.setStartIndex(1); query.setMaxFeatures(2); int count = dataStore.getFeatureSource("riverFullPlaceHolder").getCount(query); assertTrue(count == 1); } }
/** * Build the query for execute on index source partial Implementation manages pagination by * itself, so remove bounds from query * * @return Query */ @Override protected Query transformQueryToIdsOnly() { Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery())); idsQuery.setProperties(getIndexQueryProperties()); idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName()); idsQuery.setStartIndex(null); idsQuery.setMaxFeatures(Integer.MAX_VALUE); return idsQuery; }
/** * Test the second page of one feature per page. * * @throws IOException */ @Test public void oneFeatureSecondPage() throws IOException { Query query = new Query(); query.setMaxFeatures(1); query.setStartIndex(1); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.2", features[0].getID()); }
/** * Test the first page of one feature per page. * * @throws IOException */ @Test public void oneFeatureFirstPage() throws IOException { Query query = new Query(); query.setMaxFeatures(1); query.setStartIndex(0); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.1", features[0].getID()); }
/** * Test the third page of one feature per page. * * @throws IOException */ @Test public void oneFeatureThirdPage() throws IOException { Query query = new Query(); query.setMaxFeatures(1); query.setStartIndex(2); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.3", features[0].getID()); }
/** * Test a page of two features that only contains one because startindex is too close to the * end. * * @throws IOException */ @Test public void twoFeaturesReturnOne() throws IOException { Query query = new Query(); query.setMaxFeatures(2); query.setStartIndex(2); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.3", features[0].getID()); }
/** * Test the third page of one feature per page with natural sorting. * * @throws IOException */ @Test public void naturalSortedOneFeatureThirdPage() throws IOException { Query query = new Query(); query.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER}); query.setMaxFeatures(1); query.setStartIndex(2); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.3", features[0].getID()); }
/** * Test the first page of one feature per page with natural sorting. * * @throws IOException */ @Test public void naturalSortedOneFeatureFirstPage() throws IOException { Query query = new Query(); query.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER}); query.setMaxFeatures(1); query.setStartIndex(0); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.1", features[0].getID()); }
public void testUniqueWithLimitOffset() throws Exception { if (!dataStore.getSQLDialect().isLimitOffsetSupported() || !dataStore.getSQLDialect().isAggregatedSortSupported("distinct")) { return; } FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("stringProperty")); UniqueVisitor v = new MyUniqueVisitor(p); Query q = new Query(tname("ft1")); q.setStartIndex(0); q.setMaxFeatures(2); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); Set result = v.getResult().toSet(); assertEquals(2, result.size()); }
public void testMaxWithLimitOffset() throws Exception { if (!dataStore.getSQLDialect().isLimitOffsetSupported()) { return; } FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); MaxVisitor v = new MyMaxVisitor(p); Query q = new Query(tname("ft1")); q.setStartIndex(0); q.setMaxFeatures(2); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(1.1, v.getResult().toDouble(), 0.01); }
public void testSumWithLimitOffset() throws Exception { if (!dataStore.getSQLDialect().isLimitOffsetSupported()) { return; } FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); SumVisitor v = new MySumVisitor(p); Query q = new Query(tname("ft1")); q.setStartIndex(0); q.setMaxFeatures(2); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(1.1, v.getResult().toDouble(), 0.01); }
public void testMinWithLimitOffset() throws Exception { if (!dataStore.getSQLDialect().isLimitOffsetSupported()) { return; } FilterFactory ff = dataStore.getFilterFactory(); PropertyName p = ff.property(aname("doubleProperty")); MinVisitor v = new MyMinVisitor(p); Query q = new Query(tname("ft1")); q.setStartIndex(0); q.setMaxFeatures(2); dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null); assertFalse(visited); assertEquals(0.0, v.getResult().toDouble(), 0.01); }