Class ALcdChunkedInputStreamFactory
- All Implemented Interfaces:
ILcdInputStreamFactory
InputStream instances 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 createChunkLoader(String).
- Since:
- 2022.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedALcdChunkedInputStreamFactory(int aSwitchLimit, int aChunkSize) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ILcdChunkLoadercreateChunkLoader(String aSource) Creates a chunk loader that is used to access the source incrementally.createInputStream(String aSource) Creates anInputStreamfromaSource.protected abstract InputStreamcreateLinearInputStream(String aSource) Creates the linear input stream that is used initially to access the source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.io.ILcdInputStreamFactory
canCreateInputStream
-
Constructor Details
-
ALcdChunkedInputStreamFactory
protected ALcdChunkedInputStreamFactory(int aSwitchLimit, int aChunkSize) Creates a new instance.- Parameters:
aSwitchLimit- the size limit, in bytes, for a skip to cause the switch from linear access to chunked accessaChunkSize- the size, in bytes, of a requested chunk
-
-
Method Details
-
createInputStream
Description copied from interface:ILcdInputStreamFactoryCreates anInputStreamfromaSource.- Specified by:
createInputStreamin interfaceILcdInputStreamFactory- Parameters:
aSource- an accessible data source.- Returns:
- an
InputStreamfrom the data source. - Throws:
IOException- whenaSourceis not accepted bycanCreateInputStreamor is not accessible.- See Also:
-
createLinearInputStream
Creates the linear input stream that is used initially to access the source. The created input stream should cover the entire data.- Parameters:
aSource- an accessible data source- Returns:
- an input stream for the data source
- Throws:
IOException- if the data source cannot be accessed
-
createChunkLoader
Creates a chunk loader that is used to access the source incrementally. This method is called when switching from linear to chunked access for the source.- Parameters:
aSource- the source for which the linear input stream was initially created- Returns:
- the loader
- Throws:
IOException- if the loader cannot be created
-