use of org.openstreetmap.osmosis.core.sort.v0_6.EntitySubClassComparator in project osmosis by openstreetmap.
the class EntityDao method getFeaturelessEntity.
private ReleasableIterator<T> getFeaturelessEntity(String tablePrefix) {
FileBasedSort<T> sortingStore;
sortingStore = new FileBasedSort<T>(new SingleClassObjectSerializationFactory(entityMapper.getEntityClass()), new EntitySubClassComparator<T>(new EntityByTypeThenIdComparator()), true);
try {
String sql;
SortingStoreRowMapperListener<T> storeListener;
RowMapperRowCallbackListener<T> rowCallbackListener;
ReleasableIterator<T> resultIterator;
sql = entityMapper.getSqlSelect(tablePrefix, false, false);
// Sends all received data into the object store.
storeListener = new SortingStoreRowMapperListener<T>(sortingStore);
// Converts result set rows into objects and passes them into the store.
rowCallbackListener = new RowMapperRowCallbackListener<T>(entityMapper.getRowMapper(), storeListener);
// Perform the query passing the row mapper chain to process rows in a streamy fashion.
jdbcTemplate.query(sql, rowCallbackListener);
// Open a iterator on the store that will release the store upon completion.
resultIterator = new StoreReleasingIterator<T>(sortingStore.iterate(), sortingStore);
// The store itself shouldn't be released now that it has been attached to the iterator.
sortingStore = null;
return resultIterator;
} finally {
if (sortingStore != null) {
sortingStore.close();
}
}
}
Aggregations