public void close() { try { reader.close(); } catch (IOException e) { // we tried, n problem } } }
public boolean hasNext() throws IOException { return delegate.hasNext(); }
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { return delegate.next(); }
@Test public void testSortNatural() throws IOException { // make it so that we are not going to hit the disk SimpleFeatureReader sr = null; try { sr = new SortedFeatureReader(fr, fidAsc, 1000); String prev = null; while (sr.hasNext()) { SimpleFeature f = sr.next(); String id = f.getID(); if (prev != null) { assertTrue(id.compareTo(prev) >= 0); } prev = id; } } finally { if (sr != null) { sr.close(); } } }
SimpleFeatureType schema = reader.getFeatureType(); if (!canSort(schema, sortBy)) { throw new IllegalArgumentException( "The specified reader cannot be sorted, either the " + "sorting properties are not comparable or the attributes are not serializable: " + reader.getFeatureType().getTypeName() + "\n " + Arrays.toString(sortBy)); try { while (reader.hasNext()) { SimpleFeature f = reader.next(); features.add(f); count++; reader.close();
private void assertSortedOnPeopleAsc(SimpleFeatureReader fr) throws IllegalArgumentException, NoSuchElementException, IOException { double prev = -1; while (fr.hasNext()) { SimpleFeature f = fr.next(); int curr = (Integer) f.getAttribute("PERSONS"); if (prev > 0) { assertTrue(curr >= prev); } prev = curr; } }
public SimpleFeatureType getFeatureType() { return delegate.getFeatureType(); }
@Test public void testSortDescending() throws IOException { // make it so that we are not going to hit the disk SimpleFeatureReader sr = null; try { sr = new SortedFeatureReader(fr, peopleDesc, 1000); double prev = -1; while (sr.hasNext()) { SimpleFeature f = sr.next(); int curr = (Integer) f.getAttribute("PERSONS"); if (prev > 0) { assertTrue(curr <= prev); } prev = curr; } } finally { if (sr != null) { sr.close(); } } }
SimpleFeatureType schema = reader.getFeatureType(); if (!canSort(schema, sortBy)) { throw new IllegalArgumentException( try { while (reader.hasNext()) { SimpleFeature f = reader.next(); features.add(f); count++; reader.close();
private void assertSortedOnDateAsc(SimpleFeatureReader fr) throws IllegalArgumentException, NoSuchElementException, IOException { Date prev = null; while (fr.hasNext()) { SimpleFeature f = fr.next(); Date curr = (Date) f.getAttribute("date"); if (prev != null) { assertTrue(prev.compareTo(curr) <= 0); } prev = curr; } }
public SimpleFeatureType getFeatureType() { return delegate.getFeatureType(); }
@Test public void testSortNaturalPartialLastPage() throws IOException { // make it so that we are not going to hit the disk, but // some of the data won't fit in the last page, used to be // left in memory and forgotten SimpleFeatureReader sr = null; try { final int PRIME = 173; sr = new SortedFeatureReader(fr, fidAsc, PRIME); String prev = null; int count = 0; while (sr.hasNext()) { SimpleFeature f = sr.next(); String id = f.getID(); if (prev != null) { assertTrue(id.compareTo(prev) >= 0); } prev = id; count++; } assertEquals(fc.size(), count); } finally { if (sr != null) { sr.close(); } } }
public void close() throws IOException { delegate.close(); }
public SimpleFeature next() { if (!hasNext()) { throw new NoSuchElementException(); } try { return reader.next(); } catch (Exception e) { throw new RuntimeException("Reader failed", e); } }
public boolean hasNext() { try { return reader.hasNext(); } catch (IOException e) { throw new RuntimeException("Reader failed", e); } }
@After public void tearDown() throws IOException { fr.close(); }
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { return delegate.next(); }
public boolean hasNext() throws IOException { return delegate.hasNext(); }
@Test public void testFileSortDate() throws IOException { // make it so that we are going to hit the disk SimpleFeatureReader sr = null; try { sr = new SortedFeatureReader(fr, dateAsc, 100); assertSortedOnDateAsc(sr); } finally { if (sr != null) { sr.close(); } } }
public SimpleFeature next() { if (!hasNext()) { throw new NoSuchElementException(); } try { return reader.next(); } catch (Exception e) { throw new RuntimeException("Reader failed", e); } }