public abstract class ALcdChunkedInputStreamFactory extends Object implements ILcdInputStreamFactory
InputStreaminstances that can access a data source without requiring a persistent connection to the data or that access happens linearly.
In some environments, e.g. in the cloud, you pay per request and per byte transferred. That is why input streams produced by this factory first try to minimize the number of requests, but switch to minimizing the number of bytes transferred when it appears that the user wants non-linear access.
Determining whether the user wants non-linear access is based on how they use the input stream.
Many decoders for tile-based image data exhibit the following access pattern: open an input stream,
skip to a known location, read some data, close the stream.
An example is the access of Cloud Optimized GeoTIFFs over the internet.
When we see "large" skips, we assume that non-linear access is wanted. In that case, rather than actually loading
all the skipped bytes, we close the linear input stream and start loading individual chunks. On the internet,
this can be done using range-requests.
What constitutes a "large" skip, is controlled by the
switch limit parameter to the constructor.
Input streams created by this factory are decorators.
The initial delegate is a regular
InputStream delegate that you instantiate in
createLinearInputStream(String). This input stream should be able to read the entire data.
When the switch to the chunk-based strategy occurs,
the linear delegate is replaced by one that uses an
ILcdChunkLoader to load chunks of data.
You instantiate the loader in
|Modifier||Constructor and Description|
Creates a new instance.
|Modifier and Type||Method and Description|
Creates a chunk loader that is used to access the source incrementally.
Creates the linear input stream that is used initially to access the source.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected ALcdChunkedInputStreamFactory(int aSwitchLimit, int aChunkSize)
aSwitchLimit- the size limit, in bytes, for a skip to cause the switch from linear access to chunked access
aChunkSize- the size, in bytes, of a requested chunk
public InputStream createInputStream(String aSource) throws IOException
aSource- an accessible data source.
InputStreamfrom the data source.
aSourceis not accepted by
canCreateInputStreamor is not accessible.
protected abstract InputStream createLinearInputStream(String aSource) throws IOException
aSource- an accessible data source
IOException- if the data source cannot be accessed
protected abstract ILcdChunkLoader createChunkLoader(String aSource) throws IOException
aSource- the source for which the linear input stream was initially created
IOException- if the loader cannot be created