Package org.opendaylight.raft.spi
Class ByteArray
java.lang.Object
org.opendaylight.raft.spi.ByteArray
- All Implemented Interfaces:
SizedStreamSource,StreamSource
@NonNullByDefault
public abstract sealed class ByteArray
extends Object
implements SizedStreamSource
The moral equivalent of a
byte[], but perhaps allocated in chunks so as to be GC-friendly.-
Method Summary
Modifier and TypeMethodDescriptionabstract List<byte[]> chunks()Returns the list of chunks.abstract voidcopyTo(DataOutput output) Copy this array into specifiedDataOutput.abstract voidcopyTo(OutputStream output) Copy this array into specifiedDataOutput.static final ByteArrayempty()Returns an emptyByteArray.abstract intReturns the size of this array.abstract InputStreamOpen anInputStream.static ByteArrayfinal longsize()Returns the size of this data source, which is to say the number of bytes available for reading from the stream returned byStreamSource.openStream().final StringtoString()static final ByteArraywrap(byte[] bytes) Wrap abyte[]in aByteArray.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opendaylight.raft.spi.SizedStreamSource
toSizedStreamSourceMethods inherited from interface org.opendaylight.raft.spi.StreamSource
openBufferedStream, openDataInput
-
Method Details
-
openStream
Description copied from interface:StreamSourceOpen anInputStream.- Specified by:
openStreamin interfaceStreamSource- Returns:
- an InputStream
-
size
public final long size()Description copied from interface:SizedStreamSourceReturns the size of this data source, which is to say the number of bytes available for reading from the stream returned byStreamSource.openStream().- Specified by:
sizein interfaceSizedStreamSource- Returns:
- the size of this data source
-
legacySize
public abstract int legacySize()Returns the size of this array.- Returns:
- the size of this array
-
copyTo
Copy this array into specifiedDataOutput.- Parameters:
output- the data output- Throws:
IOException- if an I/O error occurs
-
copyTo
Copy this array into specifiedDataOutput.- Parameters:
output- the data output- Throws:
IOException- if an I/O error occurs
-
chunks
Returns the list of chunks.- Returns:
- the list of chunks
-
empty
Returns an emptyByteArray.- Returns:
- an empty
ByteArray
-
wrap
Wrap abyte[]in aByteArray.- Parameters:
bytes- bytes to wrap- Returns:
- a
ByteArray
-
readFrom
- Parameters:
in- the inputsize- size of inputchunkSize- target chunk size- Returns:
- a
ByteArray - Throws:
IOException- if an I/O error occurs
-
toString
-