use of org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory 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();
}
}
}
use of org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory 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();
}
}
}
Aggregations