query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures(); query.setStartIndex(null); query.setMaxFeatures(Query.DEFAULT_MAX); } else { query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures(); query.setStartIndex(null); query.setMaxFeatures(Query.DEFAULT_MAX);
result.setStartIndex(userQuery.getStartIndex()); result.setSortBy(userQuery.getSortBy());
/** * 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; }
private Query queryWithLimits(int lower, int upper) { Query query = new Query(tname("buildings")); query.setStartIndex(lower); query.setMaxFeatures(upper); return query; }
public void testCountWithOffsetLimit() throws Exception { Query query = new Query(); query.setStartIndex(1); query.setMaxFeatures(1); assertEquals(1, featureSource.getCount(query)); }
/** * 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; }
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); } }
/** * 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 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()); }
/** * 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 reverse sorting. * * @throws IOException */ @Test public void reverseSortedOneFeatureFirstPage() throws IOException { Query query = new Query(); query.setSortBy(new SortBy[] {SortBy.REVERSE_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.3", features[0].getID()); }
/** * Test the second page of one feature per page with reverse sorting. * * @throws IOException */ @Test public void reverseSortedOneFeatureSecondPage() throws IOException { Query query = new Query(); query.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER}); 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 two features per page. * * @throws IOException */ @Test public void twoFeaturesFirstPage() throws IOException { Query query = new Query(); query.setMaxFeatures(2); query.setStartIndex(0); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(2, fs.getCount(query)); Assert.assertEquals("mock.1", features[0].getID()); Assert.assertEquals("mock.2", features[1].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); }