public int getCount(Query query) throws IOException { return delegate.getCount(query); }
public int getCount(Query query) throws IOException { return wrapped.getCount(store.retypeQuery(query, typeMap)); }
/** * Adjust query and forward to source. * * <p>This method provides access to an optimized getCount opperation. If no optimized * opperation is available <code>-1</code> will be returned. * * <p>You may still make use of getFeatures( Query ).getCount() which will return the correct * answer (even if it has to itterate through all the results to do so). * * @param query User's query. * @return Number of Features for Query, or -1 if no optimization is available. */ public int getCount(Query query) { try { query = makeDefinitionQuery(query, schema); } catch (IOException ex) { return -1; } try { return source.getCount(query); } catch (IOException e) { return 0; } }
public int getCount(Query query) throws IOException { return wrapped.getCount(query); }
public int getCount(Query query) throws IOException { return fsource.getCount(query); }
@Override public int getCount(Query query) throws IOException { // transforming does not change count, but we have to transform the filter Query txQuery = transformer.transformQuery(query); txQuery.setPropertyNames(Query.ALL_NAMES); // let the world know if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log( Level.FINE, "The original query for count computation{0} has been transformed to {1}", new Object[] {query, txQuery}); } return source.getCount(txQuery); }
public int getCount(Query query) throws IOException { // SimpleFeatureSource fs = getFeatureSourceFor(query); // Query newQuery=getProxyObject(query, fs); // return fs.getCount(newQuery); Query newQuery = getProxyObject(query, getBaseFeatureSource()); return getBaseFeatureSource().getCount(newQuery); }
public void testMaxFeatureOptimized() throws Exception { DefaultQuery q = new DefaultQuery("roads"); q.setMaxFeatures(10); // mock up the feature source so that it'll return a count of 20 SimpleFeatureType type = DataUtilities.createType("roads", "_=the_geom:Point,FID:String,NAME:String"); SimpleFeatureSource fs = createMock(SimpleFeatureSource.class); expect(fs.getSchema()).andReturn(type).anyTimes(); expect(fs.getCount(q)).andReturn(20); replay(fs); DefaultFeatureResults results = new DefaultFeatureResults(fs, q); assertEquals(10, results.size()); }
public void testGetCount() throws Exception { SimpleFeatureSource view = getView(); Query query = getQuery(); int count = view.getCount(query); assertEquals(1, count); }
private void testReset(int limit) throws IOException { DefaultProgressListener listener = new DefaultProgressListener(); try (MarkFeatureIterator iterator = MarkFeatureIterator.create(zroads.getFeatures(), limit, listener)) { if (limit >= zroads.getCount(Query.ALL)) { assertTrue(iterator instanceof MemoryMarkFeatureIterator); } else { assertTrue(iterator instanceof DiskMarkFeatureIterator); } iterator.mark(); assertThreeFeatures(iterator); iterator.reset(); assertThreeFeatures(iterator); } }
/** * 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 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 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 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()); }
void assertDatesMatch(Query query, String... dates) throws Exception { SimpleFeatureSource source = dataStore.getFeatureSource(tname("dates")); assertEquals(dates.length, source.getCount(query)); SimpleFeatureCollection features = source.getFeatures(query); try (SimpleFeatureIterator it = features.features()) { int i = 0; while (it.hasNext()) { SimpleFeature f = it.next(); Date expected = date(dates[i++]); assertEquals( Converters.convert(expected, Timestamp.class), f.getAttribute(aname("dt"))); } } }
/** * Test that the default query returns all features unsorted. * * @throws IOException */ @Test public void defaultFeatures() throws IOException { Query query = new Query(); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(3, fs.getCount(query)); Assert.assertEquals("mock.3", features[0].getID()); Assert.assertEquals("mock.1", features[1].getID()); Assert.assertEquals("mock.2", features[2].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 testSource() throws Exception { SimpleFeatureSource s = DataUtilities.source(roadFeatures); assertEquals(3, s.getCount(Query.ALL)); assertEquals(3, s.getFeatures().size()); assertEquals(3, s.getFeatures(Query.ALL).size()); assertEquals(3, s.getFeatures(Filter.INCLUDE).size()); assertEquals(0, s.getFeatures(Filter.EXCLUDE).size()); assertEquals(1, s.getFeatures(rd1Filter).size()); assertEquals(2, s.getFeatures(rd12Filter).size()); }