Modifier and Type | Class and Description |
---|---|
static class |
CacheDataSink.CacheDataSinkException
Thrown when IOException is encountered when writing data into sink.
|
Constructor and Description |
---|
CacheDataSink(Cache cache,
long maxCacheFileSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the
DataSink . |
DataSink |
open(DataSpec dataSpec)
Opens the
DataSink to consume the specified data. |
void |
write(byte[] buffer,
int offset,
int length)
Consumes the provided data.
|
public CacheDataSink(Cache cache, long maxCacheFileSize)
cache
- The cache into which data should be written.maxCacheFileSize
- The maximum size of a cache file, in bytes. If the sink is opened for
a DataSpec
whose size exceeds this value, then the data will be fragmented into
multiple cache files.public DataSink open(DataSpec dataSpec) throws CacheDataSink.CacheDataSinkException
DataSink
DataSink
to consume the specified data. Calls to DataSink.open(DataSpec)
and
DataSink.close()
must be balanced.open
in interface DataSink
dataSpec
- Defines the data to be consumed.DataSink
, for convenience.CacheDataSink.CacheDataSinkException
public void write(byte[] buffer, int offset, int length) throws CacheDataSink.CacheDataSinkException
DataSink
write
in interface DataSink
buffer
- The buffer from which data should be consumed.offset
- The offset of the data to consume in buffer
.length
- The length of the data to consume, in bytes.CacheDataSink.CacheDataSinkException
public void close() throws CacheDataSink.CacheDataSinkException
DataSink
DataSink
.close
in interface DataSink
CacheDataSink.CacheDataSinkException