public static <T> int writeList(Buffer.Writer<T> writer, List<T> value, byte[] out, int pos) { if (value.isEmpty()) { out[pos++] = '['; out[pos++] = ']'; return 2; } int initialPos = pos; Buffer result = new Buffer(out, pos); writeList(writer, value, result); return result.pos - initialPos; }
int writeList(List<Span> spans, byte[] out, int pos) { int lengthOfSpans = spans.size(); if (lengthOfSpans == 0) return 0; Buffer result = new Buffer(out, pos); for (int i = 0; i < lengthOfSpans; i++) { SPAN.write(result, spans.get(i)); } return result.pos - pos; } }
public int writeList(List<Span> spans, byte[] out, int pos) { int lengthOfSpans = spans.size(); if (lengthOfSpans == 0) return 0; Buffer result = new Buffer(out, pos); ThriftCodec.writeList(this, spans, result); return result.pos() - pos; }
public static boolean read(byte[] bytes, Collection<Span> out) { if (bytes.length == 0) return false; Buffer buffer = new Buffer(bytes, 0); try { Span span = SPAN.read(buffer); if (span == null) return false; out.add(span); return true; } catch (Exception e) { throw exceptionReading("Span", e); } }
public static boolean readList(byte[] bytes, Collection<Span> out) { int length = bytes.length; if (length == 0) return false; Buffer buffer = new Buffer(bytes, 0); try { while (buffer.pos < length) { Span span = SPAN.read(buffer); if (span == null) return false; out.add(span); } } catch (Exception e) { throw exceptionReading("List<Span>", e); } return true; }
public static <T> byte[] writeList(Buffer.Writer<T> writer, List<T> value) { if (value.isEmpty()) return new byte[] {'[', ']'}; Buffer result = new Buffer(sizeInBytes(writer, value)); writeList(writer, value, result); return result.toByteArray(); }
public byte[] writeList(List<Span> spans) { int lengthOfSpans = spans.size(); if (lengthOfSpans == 0) return EMPTY_ARRAY; Buffer result = new Buffer(ThriftCodec.listSizeInBytes(this, spans)); ThriftCodec.writeList(this, spans, result); return result.toByteArray(); }
public static @Nullable Span readOne(byte[] bytes) { return SPAN.read(new Buffer(bytes, 0)); }
/** Writes the current instance in TBinaryProtocol */ public ByteBuffer toThrift() { Buffer buffer = new Buffer(sizeInBytes()); write(buffer); return ByteBuffer.wrap(buffer.toByteArray()); }
/** Encodes per ListOfSpans data wireType, where field one is repeated spans */ public byte[] writeList(List<Span> spans) { int lengthOfSpans = spans.size(); if (lengthOfSpans == 0) return EMPTY_ARRAY; if (lengthOfSpans == 1) return write(spans.get(0)); int sizeInBytes = 0; int[] sizeOfValues = new int[lengthOfSpans]; for (int i = 0; i < lengthOfSpans; i++) { int sizeOfValue = sizeOfValues[i] = SPAN.sizeOfValue(spans.get(i)); sizeInBytes += sizeOfLengthDelimitedField(sizeOfValue); } Buffer result = new Buffer(sizeInBytes); for (int i = 0; i < lengthOfSpans; i++) { writeSpan(spans.get(i), sizeOfValues[i], result); } return result.toByteArray(); }
public byte[] write(Span onlySpan) { Buffer result = new Buffer(sizeInBytes(onlySpan)); write(onlySpan, result); return result.toByteArray(); }
Buffer b = new Buffer(writer.sizeInBytes(value)); try { writer.write(value, b);
static byte[] legacyEndpointBytes(@Nullable Endpoint localEndpoint) { if (localEndpoint == null) return null; Buffer buffer = new Buffer(ThriftEndpointCodec.sizeInBytes(localEndpoint)); ThriftEndpointCodec.write(localEndpoint, buffer); return buffer.toByteArray(); }
static byte[] legacyEndpointBytes(@Nullable Endpoint localEndpoint) { if (localEndpoint == null) return null; Buffer buffer = new Buffer(endpointSizeInBytes(localEndpoint, true)); V2SpanWriter.writeEndpoint(localEndpoint, buffer, true); return buffer.toByteArray(); }
byte[] write(Span onlySpan) { int sizeOfValue = SPAN.sizeOfValue(onlySpan); Buffer result = new Buffer(sizeOfLengthDelimitedField(sizeOfValue)); writeSpan(onlySpan, sizeOfValue, result); return result.toByteArray(); }