Class ChunkedValueInputStream
java.lang.Object
java.io.InputStream
com.linkedin.davinci.storage.chunking.ChunkedValueInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
This
InputStream implementation allows us to pass a value made up of many chunks into the Avro decoder
without stitching it up into a single big byte array. This is in the hope of avoiding humongous allocations
and being more GC-efficient.
NOT intended for multi-threaded usage.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintread()Required part of theInputStreamcontract, although we hope that it will generally not be called, as the alternativeread(byte[], int, int)function is more efficient.intread(byte[] b, int off, int len) This function is an optional, but recommended, part of theInputStreamcontract.voidsetChunk(int chunkIndex, byte[] chunkContent) Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
ChunkedValueInputStream
public ChunkedValueInputStream(int numberOfChunks)
-
-
Method Details
-
setChunk
public void setChunk(int chunkIndex, byte[] chunkContent) -
read
Required part of theInputStreamcontract, although we hope that it will generally not be called, as the alternativeread(byte[], int, int)function is more efficient. Still, we provide this mandatory function in case any code needs to do byte-by-byte consumption.- Specified by:
readin classInputStream- Throws:
IOException
-
read
This function is an optional, but recommended, part of theInputStreamcontract. It is more optimal thanInputStream.read(byte[], int, int)which internally iterates over our ownread()implementation, one byte at a time.- Overrides:
readin classInputStream- Throws:
IOException
-