query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures(); offset = query.getStartIndex(); maxFeatures = query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
private String getNextFromVisitor() { // if max features reached, no more items. if (counter >= idQuery.getMaxFeatures()) return null; if (visitorIterator.hasNext()) { counter++; return (String) visitorIterator.next(); } else { // if next current visitor start is into bounds int nextStart = currentVisitorStart + STEP_LOAD; if (nextStart <= (start + max - 1)) { // init new visitor, next bounds currentVisitorStart = nextStart; initVisitor(); // if don't have next value yet, no more data -> return null if (!visitorIterator.hasNext()) return null; // has next value, return it counter++; return (String) visitorIterator.next(); } } return null; }
public JTSIndexVisitorAdapter(final GranuleCatalogVisitor adaptee, Query q) { this.adaptee = adaptee; this.filter = q == null ? Query.ALL.getFilter() : q.getFilter(); this.maxGranules = q.getMaxFeatures(); }
/** * Applies the limit/offset elements to the query if they are specified and if the dialect * supports them * * @param sql The sql to be modified * @param the query that holds the limit and offset parameters */ public void applyLimitOffset(StringBuffer sql, Query query) { applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures()); }
public IndexUniqueVisitorIterator( FeatureCollection<SimpleFeatureType, SimpleFeature> fc, Query idQuery, String idFieldName) { super(); this.fc = fc; this.idQuery = idQuery; this.idFieldName = idFieldName; this.start = idQuery.getStartIndex() != null ? idQuery.getStartIndex() : 0; this.max = idQuery.getMaxFeatures(); currentVisitorStart = this.start; initVisitor(); }
/** * Hashcode based on all parameters other than the handle. * * @return hascode for this Query */ @Override public int hashCode() { String[] n = getPropertyNames(); return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode()))) | getMaxFeatures() | ((getFilter() == null) ? 0 : getFilter().hashCode()) | ((getTypeName() == null) ? 0 : getTypeName().hashCode()) | ((getVersion() == null) ? 0 : getVersion().hashCode()) | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode()) | ((getCoordinateSystemReproject() == null) ? 0 : getCoordinateSystemReproject().hashCode()) | getStartIndex(); }
/** 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()); }
protected PreparedStatement selectJoinSQLPS( SimpleFeatureType featureType, JoinInfo join, Query query, Connection cx) throws SQLException, IOException { StringBuffer sql = new StringBuffer(); sql.append("SELECT "); selectColumns(featureType, join.getPrimaryAlias(), query, sql); // joined columns for (JoinPart part : join.getParts()) { selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql); } sql.setLength(sql.length() - 1); dialect.encodePostSelect(featureType, sql); sql.append(" FROM "); // join clauses encodeTableJoin(featureType, join, query, sql); // filtering List<FilterToSQL> toSQLs = encodeWhereJoin(featureType, join, sql); // sorting sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql); // finally encode limit/offset, if necessary applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures()); LOGGER.fine(sql.toString()); PreparedStatement ps = cx.prepareStatement( sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ps.setFetchSize(fetchSize); setPreparedFilterValues(ps, toSQLs, cx); return ps; }
applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
protected String selectJoinSQL(SimpleFeatureType featureType, JoinInfo join, Query query) throws IOException, SQLException { StringBuffer sql = new StringBuffer(); sql.append("SELECT "); // column names selectColumns(featureType, join.getPrimaryAlias(), query, sql); // joined columns for (JoinPart part : join.getParts()) { selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql); } sql.setLength(sql.length() - 1); dialect.encodePostSelect(featureType, sql); // from sql.append(" FROM "); // join clauses encodeTableJoin(featureType, join, query, sql); // filtering encodeWhereJoin(featureType, join, sql); // TODO: sorting sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql); // finally encode limit/offset, if necessary applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures()); return sql.toString(); }
if (txQuery.getMaxFeatures() > query.getMaxFeatures()) { transformed = new MaxFeaturesIterator(transformed, query.getMaxFeatures());
/** * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for the geometry attributes only, * designed for bounds computation */ protected FeatureReader<SimpleFeatureType, SimpleFeature> boundsReader() throws IOException { List attributes = new ArrayList(); SimpleFeatureType schema = featureSource.getSchema(); for (int i = 0; i < schema.getAttributeCount(); i++) { AttributeDescriptor at = schema.getDescriptor(i); if (at instanceof GeometryDescriptorImpl) attributes.add(at.getLocalName()); } DefaultQuery q = new DefaultQuery(query); q.setPropertyNames(attributes); FeatureReader<SimpleFeatureType, SimpleFeature> reader = ((DataStore) featureSource.getDataStore()).getFeatureReader(q, getTransaction()); int maxFeatures = query.getMaxFeatures(); if (maxFeatures == Integer.MAX_VALUE) { return reader; } else { return new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } }
/** * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for this Query * * @return FeatureReader<SimpleFeatureType, SimpleFeature> for this Query * @throws IOException If results could not be obtained */ public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = ((DataStore) featureSource.getDataStore()) .getFeatureReader(query, getTransaction()); int maxFeatures = query.getMaxFeatures(); if (maxFeatures != Integer.MAX_VALUE) { reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } if (transform != null) { reader = new ReprojectFeatureReader(reader, getSchema(), transform); } return reader; }
size -= query.getStartIndex(); return Math.min(size, query.getMaxFeatures());
int maxFeatures = query.getMaxFeatures(); return (count < maxFeatures) ? count : maxFeatures;
/** * Copy contructor. * * @param query the query to copy */ public Query(Query query) { this( query.getTypeName(), query.getNamespace(), query.getFilter(), query.getMaxFeatures(), query.getProperties(), query.getHandle()); this.sortBy = query.getSortBy(); this.coordinateSystem = query.getCoordinateSystem(); this.coordinateSystemReproject = query.getCoordinateSystemReproject(); this.version = query.getVersion(); this.hints = query.getHints(); this.startIndex = query.getStartIndex(); this.alias = query.getAlias(); this.joins = new ArrayList(); for (Join j : query.getJoins()) { this.joins.add(new Join(j)); } }
private Query namedQuery(Query query) { Query namedQuery = namedQuery( query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery); namedQuery.setProperties(query.getProperties()); namedQuery.setCoordinateSystem(query.getCoordinateSystem()); namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject()); namedQuery.setHandle(query.getHandle()); namedQuery.setMaxFeatures(query.getMaxFeatures()); namedQuery.setStartIndex(query.getStartIndex()); namedQuery.setSortBy(query.getSortBy()); namedQuery.setHints(query.getHints()); if (query instanceof JoiningQuery) { ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins()); ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping()); } return namedQuery; }
if (sourceFeaturesCounter >= (start + query.getMaxFeatures())) { return false;
/** * Copy contructor, clones the state of a generic Query into a DefaultQuery * * @param query */ public DefaultQuery(Query query) { this( query.getTypeName(), query.getNamespace(), query.getFilter(), query.getMaxFeatures(), query.getProperties(), query.getHandle()); this.sortBy = query.getSortBy(); this.coordinateSystem = query.getCoordinateSystem(); this.coordinateSystemReproject = query.getCoordinateSystemReproject(); this.version = query.getVersion(); this.hints = query.getHints(); this.startIndex = query.getStartIndex(); this.alias = query.getAlias(); this.joins = query.getJoins(); } }
protected GetFeatureRequest createGetFeature(Query query, ResultType resultType) throws IOException { GetFeatureRequest request = client.createGetFeatureRequest(); final WFSDataStore dataStore = getDataStore(); final QName remoteTypeName = dataStore.getRemoteTypeName(getEntry().getName()); final SimpleFeatureType remoteSimpleFeatureType; remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName); request.setTypeName(remoteTypeName); request.setFullType(remoteSimpleFeatureType); invertAxisInFilterIfNeeded(query, remoteSimpleFeatureType); request.setFilter(query.getFilter()); request.setResultType(resultType); request.setHints(query.getHints()); int maxFeatures = query.getMaxFeatures(); if (Integer.MAX_VALUE > maxFeatures) { request.setMaxFeatures(maxFeatures); } // let the request decide request.setOutputFormat(outputFormat); request.setPropertyNames(query.getPropertyNames()); request.setSortBy(query.getSortBy()); String srsName = getSupportedSrsName(request, query); request.setSrsName(srsName); return request; }