Class StatelessMarshalerUtil
- java.lang.Object
-
- io.opentelemetry.exporter.internal.marshal.StatelessMarshalerUtil
-
public final class StatelessMarshalerUtil extends java.lang.ObjectMarshaler 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 Classes Modifier and Type Class Description private static classStatelessMarshalerUtil.Grouper<T>private static classStatelessMarshalerUtil.RepeatedElementPairSizeCalculator<K,V>private static classStatelessMarshalerUtil.RepeatedElementSizeCalculator<T>
-
Field Summary
Fields Modifier and Type Field Description private static MarshalerContext.KeyATTRIBUTES_SIZE_CALCULATOR_KEYprivate static MarshalerContext.KeyGROUPER_KEYprivate static intMAX_INNER_LOOP_SIZEprivate static longMOST_SIGNIFICANT_BIT_MASK
-
Constructor Summary
Constructors Modifier Constructor Description privateStatelessMarshalerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static intcountNegative(byte[] bytes)Returns the count of bytes with negative value.private static intencodedUtf8Length(java.lang.String string)private static intencodedUtf8LengthGeneral(java.lang.String string, int start)private static voidencodeUtf8(CodedOutputStream output, java.lang.String in)(package private) static intgetUtf8Size(java.lang.String string, boolean useUnsafe)private static intgetUtf8Size(java.lang.String string, MarshalerContext context)Returns the size of utf8 encoded string in bytes.static <T> java.util.Map<Resource,java.util.Map<InstrumentationScopeInfo,java.util.List<T>>>groupByResourceAndScope(java.util.Collection<T> dataList, java.util.function.Function<T,Resource> getResource, java.util.function.Function<T,InstrumentationScopeInfo> getInstrumentationScope, MarshalerContext context)Groups SDK items by resource and instrumentation scope.private static intsizeBytes(ProtoFieldInfo field, int length)Returns the size of a bytes field.static <K,V>
intsizeMessageWithContext(ProtoFieldInfo field, K key, V value, StatelessMarshaler2<K,V> marshaler, MarshalerContext context)Returns the size of a message field.static <T> intsizeMessageWithContext(ProtoFieldInfo field, T element, StatelessMarshaler<T> marshaler, MarshalerContext context)Returns the size of a message field.static intsizeRepeatedMessageWithContext(ProtoFieldInfo field, Attributes attributes, StatelessMarshaler2<AttributeKey<?>,java.lang.Object> marshaler, MarshalerContext context)Returns the size of a repeated message field.static <T> intsizeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.Collection<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context, MarshalerContext.Key key)Returns the size of a repeated message field.static <T> intsizeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context)Returns the size of a repeated message field.static <K,V>
intsizeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.Map<K,V> messages, StatelessMarshaler2<K,V> marshaler, MarshalerContext context, MarshalerContext.Key key)Returns the size of a repeated message field.static intsizeStringWithContext(ProtoFieldInfo field, java.lang.String value, MarshalerContext context)Returns the size of a string field.(package private) static voidwriteUtf8(CodedOutputStream output, java.lang.String string, int utf8Length, boolean useUnsafe)(package private) static voidwriteUtf8(CodedOutputStream output, java.lang.String string, int utf8Length, MarshalerContext context)Write utf8 encoded string to output stream.
-
-
-
Field Detail
-
GROUPER_KEY
private static final MarshalerContext.Key GROUPER_KEY
-
ATTRIBUTES_SIZE_CALCULATOR_KEY
private static final MarshalerContext.Key ATTRIBUTES_SIZE_CALCULATOR_KEY
-
MAX_INNER_LOOP_SIZE
private static final int MAX_INNER_LOOP_SIZE
- See Also:
- Constant Field Values
-
MOST_SIGNIFICANT_BIT_MASK
private static final long MOST_SIGNIFICANT_BIT_MASK
- See Also:
- Constant Field Values
-
-
Method Detail
-
groupByResourceAndScope
public static <T> java.util.Map<Resource,java.util.Map<InstrumentationScopeInfo,java.util.List<T>>> groupByResourceAndScope(java.util.Collection<T> dataList, java.util.function.Function<T,Resource> getResource, java.util.function.Function<T,InstrumentationScopeInfo> getInstrumentationScope, MarshalerContext context)
Groups SDK items by resource and instrumentation scope.
-
sizeStringWithContext
public static int sizeStringWithContext(ProtoFieldInfo field, @Nullable java.lang.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
private static int sizeBytes(ProtoFieldInfo field, int length)
Returns the size of a bytes field.
-
sizeRepeatedMessageWithContext
public static <T> int sizeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.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, java.util.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, java.util.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<?>,java.lang.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
private static int getUtf8Size(java.lang.String string, MarshalerContext context)Returns the size of utf8 encoded string in bytes.
-
getUtf8Size
static int getUtf8Size(java.lang.String string, boolean useUnsafe)
-
countNegative
private static int countNegative(byte[] bytes)
Returns the count of bytes with negative value.
-
encodedUtf8Length
private static int encodedUtf8Length(java.lang.String string)
-
encodedUtf8LengthGeneral
private static int encodedUtf8LengthGeneral(java.lang.String string, int start)
-
writeUtf8
static void writeUtf8(CodedOutputStream output, java.lang.String string, int utf8Length, MarshalerContext context) throws java.io.IOException
Write utf8 encoded string to output stream.- Throws:
java.io.IOException
-
writeUtf8
static void writeUtf8(CodedOutputStream output, java.lang.String string, int utf8Length, boolean useUnsafe) throws java.io.IOException
- Throws:
java.io.IOException
-
encodeUtf8
private static void encodeUtf8(CodedOutputStream output, java.lang.String in) throws java.io.IOException
- Throws:
java.io.IOException
-
-