Class MarshalerContext
java.lang.Object
io.opentelemetry.exporter.internal.marshal.MarshalerContext
Class for keeping marshaling state. The state consists of integers, that we call sizes, and
objects, that we call data. Both integers and objects can be read from the state in the order
they were added (first in, first out). Additionally, this class provides various pools and caches
for objects that can be reused between marshalling attempts.
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
static class
This class is internal and is hence not for public use.private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object[]
private int
private int
private Object[]
private static final AtomicInteger
private final MarshalerContext.Pool
<List<?>> private final MarshalerContext.Pool
<Map<?, ?>> private final boolean
private final boolean
private int
private int[]
private int
private final MarshalerContext.IdPool
private final MarshalerContext.IdPool
-
Constructor Summary
ConstructorsConstructorDescriptionMarshalerContext
(boolean marshalStringNoAllocation, boolean marshalStringUnsafe) -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
addSize()
void
addSize
(int size) <T> T
<K,
V> Map <K, V> Returns a pooled identity map.<T> T
getInstance
(MarshalerContext.Key key, Supplier<T> supplier) <T> List
<T> getList()
Returns a pooled list.int
getSize()
byte[]
Returns a buffer that can be used to hold a span id.byte[]
Returns a buffer that can be used to hold a trace id.private void
private void
static MarshalerContext.Key
key()
boolean
boolean
void
reset()
Reset context so that it could be reused.void
Reset context so that serialization could be re-run.void
setSize
(int index, int size)
-
Field Details
-
marshalStringNoAllocation
private final boolean marshalStringNoAllocation -
marshalStringUnsafe
private final boolean marshalStringUnsafe -
sizes
private int[] sizes -
sizeReadIndex
private int sizeReadIndex -
sizeWriteIndex
private int sizeWriteIndex -
data
-
dataReadIndex
private int dataReadIndex -
dataWriteIndex
private int dataWriteIndex -
traceIdPool
-
spanIdPool
-
mapPool
-
listPool
-
KEY_INDEX
-
instances
-
-
Constructor Details
-
MarshalerContext
public MarshalerContext() -
MarshalerContext
public MarshalerContext(boolean marshalStringNoAllocation, boolean marshalStringUnsafe)
-
-
Method Details
-
marshalStringNoAllocation
public boolean marshalStringNoAllocation() -
marshalStringUnsafe
public boolean marshalStringUnsafe() -
addSize
public void addSize(int size) -
addSize
public int addSize() -
growSizeIfNeeded
private void growSizeIfNeeded() -
setSize
public void setSize(int index, int size) -
getSize
public int getSize() -
addData
-
growDataIfNeeded
private void growDataIfNeeded() -
getData
-
getTraceIdBuffer
public byte[] getTraceIdBuffer()Returns a buffer that can be used to hold a trace id. -
getSpanIdBuffer
public byte[] getSpanIdBuffer()Returns a buffer that can be used to hold a span id. -
getIdentityMap
Returns a pooled identity map. -
getList
Returns a pooled list. -
resetReadIndex
public void resetReadIndex()Reset context so that serialization could be re-run. -
reset
public void reset()Reset context so that it could be reused. -
key
-
getInstance
-