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 classAbstract base class for buffered encoders.private static final classAnCodedOutputStreamthat decorates anOutputStream. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe buffer size used innewInstance(OutputStream).private static final ThreadLocal<CodedOutputStream.OutputStreamEncoder> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcomputeBoolSizeNoTag(boolean unused) Compute the number of bytes that would be needed to encode aboolfield.static intcomputeByteArraySizeNoTag(byte[] value) Compute the number of bytes that would be needed to encode abytesfield.static intCompute the number of bytes that would be needed to encode abytesfield.static intcomputeDoubleSizeNoTag(double unused) Compute the number of bytes that would be needed to encode adoublefield, including tag.(package private) static intcomputeEnumSizeNoTag(int value) Compute the number of bytes that would be needed to encode an enum field.(package private) static intcomputeFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode afixed32field.(package private) static intcomputeFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode afixed64field.(package private) static intcomputeFloatSizeNoTag(float unused) Compute the number of bytes that would be needed to encode afloatfield, including tag.(package private) static intcomputeInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode anint32field, including tag.static intcomputeInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode anint64field, including tag.(package private) static intcomputeLengthDelimitedFieldSize(int fieldLength) (package private) static intcomputeSFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode ansfixed32field.(package private) static intcomputeSFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode ansfixed64field.(package private) static intcomputeSInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode ansint32field.(package private) static intcomputeSInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode ansint64field.(package private) static intcomputeTagSize(int fieldNumber) Compute the number of bytes that would be needed to encode a tag.(package private) static intcomputeUInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode auint32field.(package private) static intcomputeUInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode auint64field, including tag.(package private) static intencodeZigZag32(int n) Encode a ZigZag-encoded 32-bit value.(package private) static longencodeZigZag64(long n) Encode a ZigZag-encoded 64-bit value.(package private) abstract voidflush()Flushes the stream and forces any buffered bytes to be written.(package private) static CodedOutputStreamnewInstance(OutputStream output) Create a newCodedOutputStreamwrapping the givenOutputStream.(package private) abstract voidwrite(byte value) (package private) abstract voidwrite(byte[] value, int offset, int length) (package private) final voidwriteBoolNoTag(boolean value) Write aboolfield to the stream.(package private) final voidwriteByteArrayNoTag(byte[] value) Write abytesfield to the stream.(package private) abstract voidwriteByteArrayNoTag(byte[] value, int offset, int length) Write abytesfield to the stream.(package private) abstract voidwriteByteBufferNoTag(ByteBuffer value) (package private) final voidwriteDoubleNoTag(double value) Write adoublefield to the stream.(package private) final voidwriteEnumNoTag(int value) Write an enum field to the stream.(package private) abstract voidwriteFixed32NoTag(int value) Write afixed32field to the stream.(package private) abstract voidwriteFixed64NoTag(long value) Write afixed64field to the stream.(package private) final voidwriteFloatNoTag(float value) Write afloatfield to the stream.(package private) abstract voidwriteInt32NoTag(int value) Write anint32field to the stream.(package private) final voidwriteInt64NoTag(long value) Write anint64field to the stream.(package private) final voidwriteRawBytes(byte[] value) Write an array of bytes.(package private) final voidwriteSFixed32NoTag(int value) Write asfixed32field to the stream.(package private) final voidwriteSFixed64NoTag(long value) Write asfixed64field to the stream.(package private) final voidwriteSInt32NoTag(int value) Write asint32field to the stream.(package private) final voidwriteSInt64NoTag(long value) Write asint64field to the stream.(package private) abstract voidwriteUInt32NoTag(int value) Write auint32field to the stream.(package private) abstract voidwriteUInt64NoTag(long value) Write auint64field 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 newCodedOutputStreamwrapping the givenOutputStream.NOTE: The provided
OutputStreamMUST 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 anint32field to the stream.- Throws:
IOException
-
writeUInt32NoTag
Write auint32field to the stream.- Throws:
IOException
-
writeSInt32NoTag
Write asint32field to the stream.- Throws:
IOException
-
writeFixed32NoTag
Write afixed32field to the stream.- Throws:
IOException
-
writeSFixed32NoTag
Write asfixed32field to the stream.- Throws:
IOException
-
writeInt64NoTag
Write anint64field to the stream.- Throws:
IOException
-
writeUInt64NoTag
Write auint64field to the stream.- Throws:
IOException
-
writeSInt64NoTag
Write asint64field to the stream.- Throws:
IOException
-
writeFixed64NoTag
Write afixed64field to the stream.- Throws:
IOException
-
writeSFixed64NoTag
Write asfixed64field to the stream.- Throws:
IOException
-
writeFloatNoTag
Write afloatfield to the stream.- Throws:
IOException
-
writeDoubleNoTag
Write adoublefield to the stream.- Throws:
IOException
-
writeBoolNoTag
Write aboolfield 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 abytesfield 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 anint32field, including tag. -
computeUInt32SizeNoTag
static int computeUInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode auint32field. -
computeSInt32SizeNoTag
static int computeSInt32SizeNoTag(int value) Compute the number of bytes that would be needed to encode ansint32field. -
computeFixed32SizeNoTag
static int computeFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode afixed32field. -
computeSFixed32SizeNoTag
static int computeSFixed32SizeNoTag(int unused) Compute the number of bytes that would be needed to encode ansfixed32field. -
computeInt64SizeNoTag
public static int computeInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode anint64field, including tag. -
computeUInt64SizeNoTag
static int computeUInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode auint64field, including tag. -
computeSInt64SizeNoTag
static int computeSInt64SizeNoTag(long value) Compute the number of bytes that would be needed to encode ansint64field. -
computeFixed64SizeNoTag
static int computeFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode afixed64field. -
computeSFixed64SizeNoTag
static int computeSFixed64SizeNoTag(long unused) Compute the number of bytes that would be needed to encode ansfixed64field. -
computeFloatSizeNoTag
static int computeFloatSizeNoTag(float unused) Compute the number of bytes that would be needed to encode afloatfield, including tag. -
computeDoubleSizeNoTag
public static int computeDoubleSizeNoTag(double unused) Compute the number of bytes that would be needed to encode adoublefield, including tag. -
computeBoolSizeNoTag
public static int computeBoolSizeNoTag(boolean unused) Compute the number of bytes that would be needed to encode aboolfield. -
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 abytesfield. -
computeByteBufferSizeNoTag
Compute the number of bytes that would be needed to encode abytesfield. -
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 abytesfield to the stream.- Throws:
IOException
-
writeByteBufferNoTag
- Throws:
IOException
-