| This is is a sample FeatureCollection implementation.
If you are a user - yes this FeatureCollection can be used to hold content in
memory.
Note/Rant to data providers:
If you are a data provider (implementing a DataStore?) please don't use this
class, you should be doing your own thing.
As an example of doing your own thing, JDBC DataStore should be making a
JDBCFeatureCollection that just maintains a Filter defining the contents.
Until such time as content is accessed for the first time; at which point the
collection can be relized by fetching a ResultSet. If possible (for a paged
result set) this may be cached for subsequent access.
Note that in a good implementation FeatureCollection will form a "chain" that
is grounded by a FeatureStore that holds the Transaction etc... It is up to
the implementor to decide what to do when an FeatureCollection in the chain
actually relizes content? Collections downstream should be able to work off
the FeatureCollection that is already relized. Note additional API may be
used, as the FeatureCollection directly creates subCollections that act views
on the origional content.
If this is too complicated (aka you don't want to break out data mining
techniques) please consider working with the following - A three tiered
approach with different assumptions at each level:
- Level 1 - All
Example:FeatureStore.getFeatures()
- represents all the content, assume this cannot fit into memory.
- don't cache unless high latency w/ modification notification or
timestamp available (aka WFS)
- use metadata for aggregate function results if available (bounds, count)
- Level 2 - Collection
Example:FeatureStore.getFeatures().getSubCollection( Filter )
Example:FeatureStore.getFeatures( Filter )
- - represents the results of a query, may cache
- - consider cache result of aggregate functions
- - consider cache data (database resultset, local hsql cache, whatever)
- - consider cache in memory (for small count)
- Level 3 - Transient
Example:FeatureStore.getFeatures().getSubCollection( Filter ).getSubCollection( Filter )
Example:FeatureCollection.getSubCollection( Filter )
- temporary collection (used to hold a Filter for subsequent opperation
and cut down on API)
Example:collection.getSubCollection( Filter ).remove()
- don't cache result, see above use
- if getSubCollection( Filter) then they are breaking out assumption, take
appropriate action.
Appropriate Action:
The above breakdown would be a good breakdown of abstract classes for
implementors to work against. However even if this is provided, there is no
excuse not to do the right thing for your datasource. And for a data source
the right thing is never to burn memory.
author: Jody Garnett |