Search in sources :

Example 1 with FileBasedSort

use of org.openstreetmap.osmosis.core.sort.common.FileBasedSort in project osmosis by openstreetmap.

the class RelationDao method getRelationMemberHistory.

private ReleasableIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>> getRelationMemberHistory(String selectedEntityStatement, SqlParameterSource parameterSource) {
    FileBasedSort<DbFeatureHistory<DbOrderedFeature<RelationMember>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbOrderedFeatureHistoryComparator<RelationMember>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<RelationMember>>> storeListener;
        DbFeatureHistoryRowMapper<DbOrderedFeature<RelationMember>> dbFeatureHistoryRowMapper;
        DbFeatureRowMapper<RelationMember> dbFeatureRowMapper;
        DbOrderedFeatureRowMapper<RelationMember> dbOrderedFeatureRowMapper;
        RelationMemberRowMapper relationNodeRowMapper;
        ReleasableIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>> resultIterator;
        sql = "SELECT rm.relation_id AS id, rm.member_id, rm.member_role, rm.member_type, rm.version, rm.sequence_id" + " FROM " + "relation_members rm" + " INNER JOIN " + selectedEntityStatement + " t ON rm.relation_id = t.relation_id AND rm.version = t.version";
        LOG.log(Level.FINER, "Relation member history query: " + sql);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(sortingStore);
        // Retrieves the version information associated with the feature.
        dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbOrderedFeature<RelationMember>>(storeListener);
        // Retrieves the sequence number associated with the feature.
        dbOrderedFeatureRowMapper = new DbOrderedFeatureRowMapper<RelationMember>(dbFeatureHistoryRowMapper);
        // Retrieves the entity information associated with the feature.
        dbFeatureRowMapper = new DbFeatureRowMapper<RelationMember>(dbOrderedFeatureRowMapper);
        // Retrieves the basic feature information.
        relationNodeRowMapper = new RelationMemberRowMapper(dbFeatureRowMapper);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        getNamedParamJdbcTemplate().query(sql, parameterSource, relationNodeRowMapper);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 2 with FileBasedSort

use of org.openstreetmap.osmosis.core.sort.common.FileBasedSort in project osmosis by openstreetmap.

the class WayDao method getWayNodeHistory.

private ReleasableIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>> getWayNodeHistory(String selectedEntityStatement, SqlParameterSource parameterSource) {
    FileBasedSort<DbFeatureHistory<DbOrderedFeature<WayNode>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbOrderedFeature<WayNode>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbOrderedFeatureHistoryComparator<WayNode>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<WayNode>>> storeListener;
        DbFeatureHistoryRowMapper<DbOrderedFeature<WayNode>> dbFeatureHistoryRowMapper;
        DbFeatureRowMapper<WayNode> dbFeatureRowMapper;
        DbOrderedFeatureRowMapper<WayNode> dbOrderedFeatureRowMapper;
        WayNodeRowMapper wayNodeRowMapper;
        ReleasableIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>> resultIterator;
        sql = "SELECT wn.way_id AS id, wn.node_id, wn.version, wn.sequence_id" + " FROM " + "way_nodes wn" + " INNER JOIN " + selectedEntityStatement + " t ON wn.way_id = t.way_id AND wn.version = t.version";
        LOG.log(Level.FINER, "Way node history query: " + sql);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<WayNode>>>(sortingStore);
        // Retrieves the version information associated with the feature.
        dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbOrderedFeature<WayNode>>(storeListener);
        // Retrieves the sequence number associated with the feature.
        dbOrderedFeatureRowMapper = new DbOrderedFeatureRowMapper<WayNode>(dbFeatureHistoryRowMapper);
        // Retrieves the entity information associated with the feature.
        dbFeatureRowMapper = new DbFeatureRowMapper<WayNode>(dbOrderedFeatureRowMapper);
        // Retrieves the basic feature information.
        wayNodeRowMapper = new WayNodeRowMapper(dbFeatureRowMapper);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        getNamedParamJdbcTemplate().query(sql, parameterSource, wayNodeRowMapper);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>>(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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 3 with FileBasedSort

use of org.openstreetmap.osmosis.core.sort.common.FileBasedSort in project osmosis by openstreetmap.

the class EntityDao method getFeaturelessEntityHistory.

private ReleasableIterator<EntityHistory<T>> getFeaturelessEntityHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
    FileBasedSort<EntityHistory<T>> sortingStore = new FileBasedSort<EntityHistory<T>>(new SingleClassObjectSerializationFactory(EntityHistory.class), new EntityHistoryComparator<T>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<EntityHistory<T>> storeListener;
        EntityHistoryRowMapper<T> entityHistoryRowMapper;
        RowMapperListener<CommonEntityData> entityRowMapper;
        EntityDataRowMapper entityDataRowMapper;
        ReleasableIterator<EntityHistory<T>> resultIterator;
        sql = buildFeaturelessEntityHistoryQuery(selectedEntityStatement);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<EntityHistory<T>>(sortingStore);
        // Retrieves the visible attribute allowing modifies to be distinguished
        // from deletes.
        entityHistoryRowMapper = new EntityHistoryRowMapper<T>(storeListener);
        // Retrieves the entity type specific columns and builds the entity objects.
        entityRowMapper = getEntityRowMapper(entityHistoryRowMapper);
        // Retrieves the common entity information.
        entityDataRowMapper = new EntityDataRowMapper(entityRowMapper, false);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        namedParamJdbcTemplate.query(sql, parameterSource, entityDataRowMapper);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<EntityHistory<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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 4 with FileBasedSort

use of org.openstreetmap.osmosis.core.sort.common.FileBasedSort in project osmosis by openstreetmap.

the class EntityDao method getTagHistory.

private ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> getTagHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
    FileBasedSort<DbFeatureHistory<DbFeature<Tag>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbFeature<Tag>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbFeatureHistoryComparator<Tag>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>> storeListener;
        DbFeatureHistoryRowMapper<DbFeature<Tag>> dbFeatureHistoryRowMapper;
        DbFeatureRowMapper<Tag> dbFeatureRowMapper;
        TagRowMapper tagRowMapper;
        ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> resultIterator;
        sql = "SELECT et." + entityName + "_id AS id, et.k, et.v, et.version" + " FROM " + entityName + "_tags et" + " INNER JOIN " + selectedEntityStatement + " t ON et." + entityName + "_id = t." + entityName + "_id AND et.version = t.version";
        LOG.log(Level.FINER, "Tag history query: " + sql);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>>(sortingStore);
        // Retrieves the version information associated with the tag.
        dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbFeature<Tag>>(storeListener);
        // Retrieves the entity information associated with the tag.
        dbFeatureRowMapper = new DbFeatureRowMapper<Tag>(dbFeatureHistoryRowMapper);
        // Retrieves the basic tag information.
        tagRowMapper = new TagRowMapper(dbFeatureRowMapper);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        namedParamJdbcTemplate.query(sql, parameterSource, tagRowMapper);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbFeature<Tag>>>(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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) DbFeature(org.openstreetmap.osmosis.core.database.DbFeature) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 5 with FileBasedSort

use of org.openstreetmap.osmosis.core.sort.common.FileBasedSort in project osmosis by openstreetmap.

the class RelationDao method getRelationMembers.

private ReleasableIterator<DbOrderedFeature<RelationMember>> getRelationMembers(String tablePrefix) {
    FileBasedSort<DbOrderedFeature<RelationMember>> sortingStore = new FileBasedSort<DbOrderedFeature<RelationMember>>(new SingleClassObjectSerializationFactory(DbOrderedFeature.class), new DbOrderedFeatureComparator<RelationMember>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbOrderedFeature<RelationMember>> storeListener;
        RowMapperRowCallbackListener<DbOrderedFeature<RelationMember>> rowCallbackListener;
        ReleasableIterator<DbOrderedFeature<RelationMember>> resultIterator;
        sql = relationMemberMapper.getSqlSelect(tablePrefix, false, false);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbOrderedFeature<RelationMember>>(sortingStore);
        // Converts result set rows into objects and passes them into the store.
        rowCallbackListener = new RowMapperRowCallbackListener<DbOrderedFeature<RelationMember>>(relationMemberMapper.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<DbOrderedFeature<RelationMember>>(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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Aggregations

FileBasedSort (org.openstreetmap.osmosis.core.sort.common.FileBasedSort)5 SingleClassObjectSerializationFactory (org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory)5 DbFeatureHistory (org.openstreetmap.osmosis.core.database.DbFeatureHistory)3 DbOrderedFeature (org.openstreetmap.osmosis.core.database.DbOrderedFeature)3 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)2 DbFeature (org.openstreetmap.osmosis.core.database.DbFeature)1 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)1 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)1 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)1