Search in sources :

Example 1 with ReleasableContainer

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;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 2 with ReleasableContainer

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;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) FeaturePopulator(org.openstreetmap.osmosis.core.database.FeaturePopulator)

Example 3 with ReleasableContainer

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;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 4 with ReleasableContainer

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;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 5 with ReleasableContainer

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;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Aggregations

ReleasableContainer (org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer)6 ReleasableIterator (org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)4 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)3 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)1 DbFeatureHistory (org.openstreetmap.osmosis.core.database.DbFeatureHistory)1 FeaturePopulator (org.openstreetmap.osmosis.core.database.FeaturePopulator)1 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)1