use of org.openstreetmap.osmosis.core.database.FeaturePopulator in project osmosis by openstreetmap.
the class EntityDao method iterate.
/**
* Returns an iterator providing access to all entities in the database.
*
* @param tablePrefix
* The prefix for the entity table name. This allows another table to be queried if
* necessary such as a temporary results table.
* @return The entity iterator.
*/
public ReleasableIterator<T> iterate(String tablePrefix) {
try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
ReleasableIterator<T> entityIterator;
List<FeaturePopulator<T>> featurePopulators;
// Create the featureless entity iterator but also store it temporarily in the
// releasable container so that it will get freed if we fail during retrieval of feature
// populators.
entityIterator = releasableContainer.add(getFeaturelessEntity(tablePrefix));
// Retrieve the feature populators also adding them to the temporary releasable container.
featurePopulators = getFeaturePopulators(tablePrefix);
for (FeaturePopulator<T> featurePopulator : featurePopulators) {
releasableContainer.add(featurePopulator);
}
// Build an entity reader capable of merging all sources together.
entityIterator = new EntityReader<T>(entityIterator, featurePopulators);
// The sources are now all attached to the history reader so we don't want to release
// them in the finally block.
releasableContainer.clear();
return entityIterator;
}
}
Aggregations