Modifier and Type | Class and Description |
---|---|
static class |
CacheDataSink.CacheDataSinkException
Thrown when IOException is encountered when writing data into sink.
|
DataSink.Factory
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Default buffer size.
|
Constructor and Description |
---|
CacheDataSink(Cache cache,
long maxCacheFileSize)
Constructs a CacheDataSink using the
DEFAULT_BUFFER_SIZE . |
CacheDataSink(Cache cache,
long maxCacheFileSize,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sink.
|
void |
open(DataSpec dataSpec)
Opens the sink to consume the specified data.
|
void |
write(byte[] buffer,
int offset,
int length)
Consumes the provided data.
|
public static final int DEFAULT_BUFFER_SIZE
public CacheDataSink(Cache cache, long maxCacheFileSize)
DEFAULT_BUFFER_SIZE
.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 CacheDataSink(Cache cache, long maxCacheFileSize, int bufferSize)
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.bufferSize
- The buffer size in bytes for writing to a cache file. A zero or negative
value disables buffering.public void open(DataSpec dataSpec) throws CacheDataSink.CacheDataSinkException
DataSink
open
in interface DataSink
dataSpec
- Defines the data to be consumed.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
close
in interface DataSink
CacheDataSink.CacheDataSinkException