Class StatelessMarshalerUtil
java.lang.Object
io.opentelemetry.exporter.internal.marshal.StatelessMarshalerUtil
Marshaler utilities.
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
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MarshalerContext.Key
private static final MarshalerContext.Key
private static final int
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
countNegative
(byte[] bytes) Returns the count of bytes with negative value.private static int
encodedUtf8Length
(String string) private static int
encodedUtf8LengthGeneral
(String string, int start) private static void
encodeUtf8
(CodedOutputStream output, String in) (package private) static int
getUtf8Size
(String string, boolean useUnsafe) private static int
getUtf8Size
(String string, MarshalerContext context) Returns the size of utf8 encoded string in bytes.static <T> Map
<Resource, Map<InstrumentationScopeInfo, List<T>>> groupByResourceAndScope
(Collection<T> dataList, Function<T, Resource> getResource, Function<T, InstrumentationScopeInfo> getInstrumentationScope, MarshalerContext context) Groups SDK items by resource and instrumentation scope.private static int
sizeBytes
(ProtoFieldInfo field, int length) Returns the size of a bytes field.static <K,
V> int sizeMessageWithContext
(ProtoFieldInfo field, K key, V value, StatelessMarshaler2<K, V> marshaler, MarshalerContext context) Returns the size of a message field.static <T> int
sizeMessageWithContext
(ProtoFieldInfo field, T element, StatelessMarshaler<T> marshaler, MarshalerContext context) Returns the size of a message field.static int
sizeRepeatedMessageWithContext
(ProtoFieldInfo field, Attributes attributes, StatelessMarshaler2<AttributeKey<?>, Object> marshaler, MarshalerContext context) Returns the size of a repeated message field.static <T> int
sizeRepeatedMessageWithContext
(ProtoFieldInfo field, Collection<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context, MarshalerContext.Key key) Returns the size of a repeated message field.static <T> int
sizeRepeatedMessageWithContext
(ProtoFieldInfo field, List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context) Returns the size of a repeated message field.static <K,
V> int sizeRepeatedMessageWithContext
(ProtoFieldInfo field, Map<K, V> messages, StatelessMarshaler2<K, V> marshaler, MarshalerContext context, MarshalerContext.Key key) Returns the size of a repeated message field.static int
sizeStringWithContext
(ProtoFieldInfo field, String value, MarshalerContext context) Returns the size of a string field.(package private) static void
writeUtf8
(CodedOutputStream output, String string, int utf8Length, boolean useUnsafe) (package private) static void
writeUtf8
(CodedOutputStream output, String string, int utf8Length, MarshalerContext context) Write utf8 encoded string to output stream.
-
Field Details
-
GROUPER_KEY
-
ATTRIBUTES_SIZE_CALCULATOR_KEY
-
MAX_INNER_LOOP_SIZE
private static final int MAX_INNER_LOOP_SIZE- See Also:
-
MOST_SIGNIFICANT_BIT_MASK
private static final long MOST_SIGNIFICANT_BIT_MASK- See Also:
-
-
Constructor Details
-
StatelessMarshalerUtil
private StatelessMarshalerUtil()
-
-
Method Details
-
groupByResourceAndScope
public static <T> Map<Resource,Map<InstrumentationScopeInfo, groupByResourceAndScopeList<T>>> (Collection<T> dataList, Function<T, Resource> getResource, Function<T, InstrumentationScopeInfo> getInstrumentationScope, MarshalerContext context) Groups SDK items by resource and instrumentation scope. -
sizeStringWithContext
public static int sizeStringWithContext(ProtoFieldInfo field, @Nullable String value, MarshalerContext context) Returns the size of a string field. This method adds elements to context, use together withSerializer.serializeStringWithContext(ProtoFieldInfo, String, MarshalerContext)
. -
sizeBytes
Returns the size of a bytes field. -
sizeRepeatedMessageWithContext
public static <T> int sizeRepeatedMessageWithContext(ProtoFieldInfo field, List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context) Returns the size of a repeated message field. This method adds elements to context, use together withSerializer.serializeRepeatedMessageWithContext(ProtoFieldInfo, List, StatelessMarshaler, MarshalerContext)
. -
sizeRepeatedMessageWithContext
public static <T> int sizeRepeatedMessageWithContext(ProtoFieldInfo field, Collection<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context, MarshalerContext.Key key) Returns the size of a repeated message field. This method adds elements to context, use together withSerializer.serializeRepeatedMessageWithContext(ProtoFieldInfo, Collection, StatelessMarshaler, MarshalerContext, MarshalerContext.Key)
. -
sizeRepeatedMessageWithContext
public static <K,V> int sizeRepeatedMessageWithContext(ProtoFieldInfo field, Map<K, V> messages, StatelessMarshaler2<K, V> marshaler, MarshalerContext context, MarshalerContext.Key key) Returns the size of a repeated message field. This method adds elements to context, use together withSerializer.serializeRepeatedMessageWithContext(ProtoFieldInfo, Map, StatelessMarshaler2, MarshalerContext, MarshalerContext.Key)
. -
sizeRepeatedMessageWithContext
public static int sizeRepeatedMessageWithContext(ProtoFieldInfo field, Attributes attributes, StatelessMarshaler2<AttributeKey<?>, Object> marshaler, MarshalerContext context) Returns the size of a repeated message field. This method adds elements to context, use together withSerializer.serializeRepeatedMessageWithContext(ProtoFieldInfo, Attributes, StatelessMarshaler2, MarshalerContext)
. -
sizeMessageWithContext
public static <T> int sizeMessageWithContext(ProtoFieldInfo field, T element, StatelessMarshaler<T> marshaler, MarshalerContext context) Returns the size of a message field. This method adds elements to context, use together withSerializer.serializeMessageWithContext(ProtoFieldInfo, Object, StatelessMarshaler, MarshalerContext)
. -
sizeMessageWithContext
public static <K,V> int sizeMessageWithContext(ProtoFieldInfo field, K key, V value, StatelessMarshaler2<K, V> marshaler, MarshalerContext context) Returns the size of a message field. This method adds elements to context, use together withSerializer.serializeMessageWithContext(ProtoFieldInfo, Object, Object, StatelessMarshaler2, MarshalerContext)
. -
getUtf8Size
Returns the size of utf8 encoded string in bytes. -
getUtf8Size
-
countNegative
private static int countNegative(byte[] bytes) Returns the count of bytes with negative value. -
encodedUtf8Length
-
encodedUtf8LengthGeneral
-
writeUtf8
static void writeUtf8(CodedOutputStream output, String string, int utf8Length, MarshalerContext context) throws IOException Write utf8 encoded string to output stream.- Throws:
IOException
-
writeUtf8
static void writeUtf8(CodedOutputStream output, String string, int utf8Length, boolean useUnsafe) throws IOException - Throws:
IOException
-
encodeUtf8
- Throws:
IOException
-