@Override protected void cleanup() throws IOException { try { flush(); } finally { for (int i = 0; i < buffer.length; i++) { if (buffer[i] == null) { break; } buffer[i].close(); buffer[i] = null; } super.cleanup(); } }
@Override public void close() throws IOException { super.close(); // we don't need to close the delegate readers because they share the same result set // and connection as this reader }
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { try { ensureOpen(); if (!hasNext()) { throw new NoSuchElementException( "No more features in this reader, you should call " + "hasNext() to check for feature availability"); } // join readers share the same resultset among many readers, won't call hasNext() on // each if (nextFeature == null) { nextFeature = readNextFeature(); } if (nextFeature == null && screenMap != null) { throw new IllegalStateException( "Feature joining currently not supported along screenmap"); } return nextFeature; } finally { // reset the next flag. We do this in a finally block to make sure we // move to the next record no matter what, if the current one could // not be read there is no salvation for it anyways nextFeature = null; next = null; } }
public JDBCFeatureReader( PreparedStatement st, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException { init(featureSource, featureType, query); // create the result set this.cx = cx; this.st = st; ((PreparedStatementSQLDialect) featureSource.getDataStore().getSQLDialect()) .onSelect(st, cx, featureType); runQuery(st::executeQuery, st); }
if (dialect instanceof PreparedStatementSQLDialect) { PreparedStatement ps = selectSQLPS(querySchema, preQuery, cx); reader = new JDBCFeatureReader(ps, cx, this, fullSchema, query); } else { reader = new JDBCFeatureReader(sql, cx, this, fullSchema, query);
new JDBCFeatureReader(rowData, cx, 0, source, tb.buildFeatureType(), new Query()); while (reader.hasNext()) { reader.next();
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { try { ensureOpen(); if(!hasNext()) { throw new NoSuchElementException("No more features in this reader, you should call " + "hasNext() to check for feature availability"); int[] attributeRsIndex = buildAttributeRsIndex(); for(int i = 0; i < attributeCount; i++) { AttributeDescriptor type = featureType.getDescriptor(i);
public JDBCFeatureReader( ResultSet rs, Connection cx, int offset, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException { init(featureSource, featureType, query); this.cx = cx; this.st = rs.getStatement(); this.rs = rs; this.offset = offset; }
public boolean hasNext() throws IOException { ensureOpen(); if (next == null) { try { while (nextFeature == null && !Boolean.FALSE.equals(next)) { callback.beforeNext(rs); next = Boolean.valueOf(rs.next()); callback.afterNext(rs, next); if (next) { nextFeature = readNextFeature(); } } if (!next) { callback.finish(this); } } catch (SQLException e) { callback.rowError(e); throw new RuntimeException(e); } } return next.booleanValue(); }
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { try { ensureOpen(); ensureNext();
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { // read the regular feature SimpleFeature f = super.next(); // rebuild it with the join feature type joinFeatureBuilder.init(f); f = joinFeatureBuilder.buildFeature(f.getID()); // add additional attributes for joined features for (int i = 0; i < joinReaders.size(); i++) { JDBCFeatureReader r = joinReaders.get(i); f.setAttribute(f.getAttributeCount() - joinReaders.size() + i, r.next()); } return f; }
public boolean hasNext() throws IOException { ensureOpen(); if (next == null) { try { next = Boolean.valueOf(rs.next()); } catch (SQLException e) { throw new RuntimeException(e); } } return next.booleanValue(); }
getDataStore().getSchema(mv.getTargetTable()), query.getPropertyNames()); reader = new JDBCFeatureReader(finalSql.toString(), cx, this, featrueType, query); } catch (Exception e) {
public JDBCFeatureReader( PreparedStatement st, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Hints hints ) throws SQLException { init( featureSource, featureType, hints ); //create the result set this.cx = cx; this.st = st; rs = st.executeQuery(); }
public JDBCFeatureReader( String sql, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException { init(featureSource, featureType, query); // create the result set this.cx = cx; st = cx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); st.setFetchSize(featureSource.getDataStore().getFetchSize()); ((BasicSQLDialect) featureSource.getDataStore().getSQLDialect()) .onSelect(st, cx, featureType); runQuery(() -> st.executeQuery(sql), st); }
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { //read the regular feature SimpleFeature f = super.next(); //rebuild it with the join feature type joinFeatureBuilder.init(f); f = joinFeatureBuilder.buildFeature(f.getID()); //add additional attributes for joined features for (int i = 0; i < joinReaders.size(); i++) { JDBCFeatureReader r = joinReaders.get(i); f.setAttribute(f.getAttributeCount() - joinReaders.size() + i, r.next()); } return f; }
public boolean hasNext() throws IOException { ensureOpen(); if (next == null) { try { next = Boolean.valueOf(rs.next()); } catch (SQLException e) { throw new RuntimeException(e); } } return next.booleanValue(); }
reader = new JDBCFeatureReader(ps, cx, this, querySchema, query); } else { getDataStore().getLogger().fine(sql); reader = new JDBCFeatureReader(sql, cx, this, querySchema, query);