Class CodedOutputStream
java.lang.Object
io.opentelemetry.exporter.internal.marshal.CodedOutputStream
- Direct Known Subclasses:
CodedOutputStream.AbstractBufferedEncoder
Protobuf wire encoder.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Abstract base class for buffered encoders.private static final class
AnCodedOutputStream
that decorates anOutputStream
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
The buffer size used innewInstance(OutputStream)
.private static final ThreadLocal
<CodedOutputStream.OutputStreamEncoder> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
computeBoolSizeNoTag
(boolean unused) Compute the number of bytes that would be needed to encode abool
field.static int
computeByteArraySizeNoTag
(byte[] value) Compute the number of bytes that would be needed to encode abytes
field.static int
Compute the number of bytes that would be needed to encode abytes
field.static int
computeDoubleSizeNoTag
(double unused) Compute the number of bytes that would be needed to encode adouble
field, including tag.(package private) static int
computeEnumSizeNoTag
(int value) Compute the number of bytes that would be needed to encode an enum field.(package private) static int
computeFixed32SizeNoTag
(int unused) Compute the number of bytes that would be needed to encode afixed32
field.(package private) static int
computeFixed64SizeNoTag
(long unused) Compute the number of bytes that would be needed to encode afixed64
field.(package private) static int
computeFloatSizeNoTag
(float unused) Compute the number of bytes that would be needed to encode afloat
field, including tag.(package private) static int
computeInt32SizeNoTag
(int value) Compute the number of bytes that would be needed to encode anint32
field, including tag.static int
computeInt64SizeNoTag
(long value) Compute the number of bytes that would be needed to encode anint64
field, including tag.(package private) static int
computeLengthDelimitedFieldSize
(int fieldLength) (package private) static int
computeSFixed32SizeNoTag
(int unused) Compute the number of bytes that would be needed to encode ansfixed32
field.(package private) static int
computeSFixed64SizeNoTag
(long unused) Compute the number of bytes that would be needed to encode ansfixed64
field.(package private) static int
computeSInt32SizeNoTag
(int value) Compute the number of bytes that would be needed to encode ansint32
field.(package private) static int
computeSInt64SizeNoTag
(long value) Compute the number of bytes that would be needed to encode ansint64
field.(package private) static int
computeTagSize
(int fieldNumber) Compute the number of bytes that would be needed to encode a tag.(package private) static int
computeUInt32SizeNoTag
(int value) Compute the number of bytes that would be needed to encode auint32
field.(package private) static int
computeUInt64SizeNoTag
(long value) Compute the number of bytes that would be needed to encode auint64
field, including tag.(package private) static int
encodeZigZag32
(int n) Encode a ZigZag-encoded 32-bit value.(package private) static long
encodeZigZag64
(long n) Encode a ZigZag-encoded 64-bit value.(package private) abstract void
flush()
Flushes the stream and forces any buffered bytes to be written.(package private) static CodedOutputStream
newInstance
(OutputStream output) Create a newCodedOutputStream
wrapping the givenOutputStream
.(package private) abstract void
write
(byte value) (package private) abstract void
write
(byte[] value, int offset, int length) (package private) final void
writeBoolNoTag
(boolean value) Write abool
field to the stream.(package private) final void
writeByteArrayNoTag
(byte[] value) Write abytes
field to the stream.(package private) abstract void
writeByteArrayNoTag
(byte[] value, int offset, int length) Write abytes
field to the stream.(package private) abstract void
writeByteBufferNoTag
(ByteBuffer value) (package private) final void
writeDoubleNoTag
(double value) Write adouble
field to the stream.(package private) final void
writeEnumNoTag
(int value) Write an enum field to the stream.(package private) abstract void
writeFixed32NoTag
(int value) Write afixed32
field to the stream.(package private) abstract void
writeFixed64NoTag
(long value) Write afixed64
field to the stream.(package private) final void
writeFloatNoTag
(float value) Write afloat
field to the stream.(package private) abstract void
writeInt32NoTag
(int value) Write anint32
field to the stream.(package private) final void
writeInt64NoTag
(long value) Write anint64
field to the stream.(package private) final void
writeRawBytes
(byte[] value) Write an array of bytes.(package private) final void
writeSFixed32NoTag
(int value) Write asfixed32
field to the stream.(package private) final void
writeSFixed64NoTag
(long value) Write asfixed64
field to the stream.(package private) final void
writeSInt32NoTag
(int value) Write asint32
field to the stream.(package private) final void
writeSInt64NoTag
(long value) Write asint64
field to the stream.(package private) abstract void
writeUInt32NoTag
(int value) Write auint32
field to the stream.(package private) abstract void
writeUInt64NoTag
(long value) Write auint64
field to the stream.
-
Field Details
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZEThe buffer size used innewInstance(OutputStream)
. -
THREAD_LOCAL_CODED_OUTPUT_STREAM
private static final ThreadLocal<CodedOutputStream.OutputStreamEncoder> THREAD_LOCAL_CODED_OUTPUT_STREAM
-
-
Constructor Details
-
CodedOutputStream
private CodedOutputStream()
-
-
Method Details
-
newInstance
Create a newCodedOutputStream
wrapping the givenOutputStream
.NOTE: The provided
OutputStream
MUST NOT retain access or modify the provided byte arrays. Doing so may result in corrupted data, which would be difficult to debug. -
writeRawBytes
Write an array of bytes.- Throws:
IOException
-
writeInt32NoTag
Write anint32
field to the stream.- Throws:
IOException
-
writeUInt32NoTag
Write auint32
field to the stream.- Throws:
IOException
-
writeSInt32NoTag
Write asint32
field to the stream.- Throws:
IOException
-
writeFixed32NoTag
Write afixed32
field to the stream.- Throws:
IOException
-
writeSFixed32NoTag
Write asfixed32
field to the stream.- Throws:
IOException
-
writeInt64NoTag
Write anint64
field to the stream.- Throws:
IOException
-
writeUInt64NoTag
Write auint64
field to the stream.- Throws:
IOException
-
writeSInt64NoTag
Write asint64
field to the stream.- Throws:
IOException
-
writeFixed64NoTag
Write afixed64
field to the stream.- Throws:
IOException
-
writeSFixed64NoTag
Write asfixed64
field to the stream.- Throws:
IOException
-
writeFloatNoTag
Write afloat
field to the stream.- Throws:
IOException
-
writeDoubleNoTag
Write adouble
field to the stream.- Throws:
IOException
-
writeBoolNoTag
Write abool
field to the stream.- Throws:
IOException
-
writeEnumNoTag
Write an enum field to the stream. The provided value is the numeric value used to represent the enum value on the wire (not the enum ordinal value).- Throws:
IOException
-
writeByteArrayNoTag
Write abytes
field to the stream.- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
computeTagSize
static int computeTagSize(int fieldNumber) Compute the number of bytes that would be needed to encode a tag. -
computeInt32SizeNoTag
static int computeInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode anint32
field, including tag. -
computeUInt32SizeNoTag
static int computeUInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode auint32
field. -
computeSInt32SizeNoTag
static int computeSInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode ansint32
field. -
computeFixed32SizeNoTag
static int computeFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode afixed32
field. -
computeSFixed32SizeNoTag
static int computeSFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode ansfixed32
field. -
computeInt64SizeNoTag
public static int computeInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode anint64
field, including tag. -
computeUInt64SizeNoTag
static int computeUInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode auint64
field, including tag. -
computeSInt64SizeNoTag
static int computeSInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode ansint64
field. -
computeFixed64SizeNoTag
static int computeFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode afixed64
field. -
computeSFixed64SizeNoTag
static int computeSFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode ansfixed64
field. -
computeFloatSizeNoTag
static int computeFloatSizeNoTag(float unused) Compute the number of bytes that would be needed to encode afloat
field, including tag. -
computeDoubleSizeNoTag
public static int computeDoubleSizeNoTag(double unused) Compute the number of bytes that would be needed to encode adouble
field, including tag. -
computeBoolSizeNoTag
public static int computeBoolSizeNoTag(boolean unused) Compute the number of bytes that would be needed to encode abool
field. -
computeEnumSizeNoTag
static int computeEnumSizeNoTag(int value) Compute the number of bytes that would be needed to encode an enum field. The provided value is the numeric value used to represent the enum value on the wire (not the enum ordinal value). -
computeByteArraySizeNoTag
public static int computeByteArraySizeNoTag(byte[] value) Compute the number of bytes that would be needed to encode abytes
field. -
computeByteBufferSizeNoTag
Compute the number of bytes that would be needed to encode abytes
field. -
computeLengthDelimitedFieldSize
static int computeLengthDelimitedFieldSize(int fieldLength) -
encodeZigZag32
static int encodeZigZag32(int n) Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)- Parameters:
n
- A signed 32-bit integer.- Returns:
- An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.
-
encodeZigZag64
static long encodeZigZag64(long n) Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)- Parameters:
n
- A signed 64-bit integer.- Returns:
- An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.
-
flush
Flushes the stream and forces any buffered bytes to be written. This does not flush the underlying OutputStream.- Throws:
IOException
-
writeByteArrayNoTag
Write abytes
field to the stream.- Throws:
IOException
-
writeByteBufferNoTag
- Throws:
IOException
-