use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.
the class AllEntityDao method getCurrent.
/**
* Retrieves all current data in the database.
*
* @return An iterator pointing at the current records.
*/
public ReleasableIterator<EntityContainer> getCurrent() {
try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
List<ReleasableIterator<EntityContainer>> sources;
MultipleSourceIterator<EntityContainer> resultIterator;
sources = new ArrayList<ReleasableIterator<EntityContainer>>();
sources.add(releasableContainer.add(nodeDao.getCurrent()));
sources.add(releasableContainer.add(wayDao.getCurrent()));
sources.add(releasableContainer.add(relationDao.getCurrent()));
resultIterator = new MultipleSourceIterator<EntityContainer>(sources);
releasableContainer.clear();
return resultIterator;
}
}
use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer 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;
}
}
use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.
the class AllEntityDao method getHistory.
/**
* Retrieves the changes that have were made by a set of transactions.
*
* @param predicates
* Contains the predicates defining the transactions to be queried.
* @return An iterator pointing at the identified records.
*/
public ReleasableIterator<ChangeContainer> getHistory(ReplicationQueryPredicates predicates) {
try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
List<ReleasableIterator<ChangeContainer>> sources;
MultipleSourceIterator<ChangeContainer> resultIterator;
sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
sources.add(releasableContainer.add(nodeDao.getHistory(predicates)));
sources.add(releasableContainer.add(wayDao.getHistory(predicates)));
sources.add(releasableContainer.add(relationDao.getHistory(predicates)));
resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
releasableContainer.clear();
return resultIterator;
}
}
use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.
the class AllEntityDao method getHistory.
/**
* Retrieves the changes that have were made between two points in time.
*
* @param intervalBegin
* Marks the beginning (inclusive) of the time interval to be checked.
* @param intervalEnd
* Marks the end (exclusive) of the time interval to be checked.
* @return An iterator pointing at the identified records.
*/
public ReleasableIterator<ChangeContainer> getHistory(Date intervalBegin, Date intervalEnd) {
try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
List<ReleasableIterator<ChangeContainer>> sources;
MultipleSourceIterator<ChangeContainer> resultIterator;
sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
sources.add(releasableContainer.add(nodeDao.getHistory(intervalBegin, intervalEnd)));
sources.add(releasableContainer.add(wayDao.getHistory(intervalBegin, intervalEnd)));
sources.add(releasableContainer.add(relationDao.getHistory(intervalBegin, intervalEnd)));
resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
releasableContainer.clear();
return resultIterator;
}
}
use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.
the class AllEntityDao method getHistory.
/**
* Retrieves all changes in the database.
*
* @return An iterator pointing at the identified records.
*/
public ReleasableIterator<ChangeContainer> getHistory() {
try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
List<ReleasableIterator<ChangeContainer>> sources;
MultipleSourceIterator<ChangeContainer> resultIterator;
sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
sources.add(releasableContainer.add(nodeDao.getHistory()));
sources.add(releasableContainer.add(wayDao.getHistory()));
sources.add(releasableContainer.add(relationDao.getHistory()));
resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
releasableContainer.clear();
return resultIterator;
}
}
Aggregations