Package com.google.protobuf
Class BinaryWriter
- java.lang.Object
-
- com.google.protobuf.ByteOutput
-
- com.google.protobuf.BinaryWriter
-
- All Implemented Interfaces:
Writer
- Direct Known Subclasses:
BinaryWriter.SafeDirectWriter
,BinaryWriter.SafeHeapWriter
,BinaryWriter.UnsafeDirectWriter
,BinaryWriter.UnsafeHeapWriter
@ExperimentalApi abstract class BinaryWriter extends ByteOutput implements Writer
A protobuf writer that serializes messages in their binary form. Messages are serialized in reverse in order to avoid calculating the serialized size of each nested message. Since the message size is not known in advance, the writer employs a strategy of chunking and buffer chaining. Buffers are allocated as-needed by a providedBufferAllocator
. Once writing is finished, the application can access the buffers in forward-writing order by callingcomplete()
.Once
complete()
has been called, the writer can not be reused for additional writes. ThegetTotalBytesWritten()
will continue to reflect the total of the write and will not be reset.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BinaryWriter.SafeDirectWriter
Writer that uses safe operations on a targetByteBuffer
.private static class
BinaryWriter.SafeHeapWriter
Writer that uses safe operations on target array.private static class
BinaryWriter.UnsafeDirectWriter
Writer that uses unsafe operations on a targetByteBuffer
.private static class
BinaryWriter.UnsafeHeapWriter
Writer that uses unsafe operations on a target array.-
Nested classes/interfaces inherited from interface com.google.protobuf.Writer
Writer.FieldOrder
-
-
Field Summary
Fields Modifier and Type Field Description private BufferAllocator
alloc
(package private) java.util.ArrayDeque<AllocatedBuffer>
buffers
private int
chunkSize
static int
DEFAULT_CHUNK_SIZE
private static int
MAP_KEY_NUMBER
private static int
MAP_VALUE_NUMBER
(package private) int
totalDoneBytes
-
Constructor Summary
Constructors Modifier Constructor Description private
BinaryWriter(BufferAllocator alloc, int chunkSize)
Only allow subclassing for inner classes.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Queue<AllocatedBuffer>
complete()
Completes the write operation and returns a queue ofAllocatedBuffer
objects in forward-writing order.private static byte
computeUInt64SizeNoTag(long value)
Not using the version in CodedOutputStream due to the fact that benchmarks have shown a performance improvement when returning a byte (rather than an int).Writer.FieldOrder
fieldOrder()
Indicates the order in which the fields are written by thisWriter
.(package private) abstract void
finishCurrentBuffer()
abstract int
getTotalBytesWritten()
Gets the total number of bytes that have been written.(package private) static boolean
isUnsafeDirectSupported()
(package private) static boolean
isUnsafeHeapSupported()
(package private) AllocatedBuffer
newDirectBuffer()
(package private) AllocatedBuffer
newDirectBuffer(int capacity)
static BinaryWriter
newDirectInstance(BufferAllocator alloc)
Creates a newBinaryWriter
that will allocate direct (i.e.static BinaryWriter
newDirectInstance(BufferAllocator alloc, int chunkSize)
Creates a newBinaryWriter
that will allocate direct (i.e.(package private) AllocatedBuffer
newHeapBuffer()
(package private) AllocatedBuffer
newHeapBuffer(int capacity)
static BinaryWriter
newHeapInstance(BufferAllocator alloc)
Creates a newBinaryWriter
that will allocate heap buffers ofDEFAULT_CHUNK_SIZE
as necessary.static BinaryWriter
newHeapInstance(BufferAllocator alloc, int chunkSize)
Creates a newBinaryWriter
that will allocate heap buffers ofchunkSize
as necessary.(package private) static BinaryWriter
newSafeDirectInstance(BufferAllocator alloc, int chunkSize)
(package private) static BinaryWriter
newSafeHeapInstance(BufferAllocator alloc, int chunkSize)
(package private) static BinaryWriter
newUnsafeDirectInstance(BufferAllocator alloc, int chunkSize)
(package private) static BinaryWriter
newUnsafeHeapInstance(BufferAllocator alloc, int chunkSize)
(package private) abstract void
requireSpace(int size)
(package private) abstract void
writeBool(boolean value)
void
writeBoolList(int fieldNumber, java.util.List<java.lang.Boolean> list, boolean packed)
Writes a list field of typeFieldType.BOOL
.private void
writeBoolList_Internal(int fieldNumber, BooleanArrayList list, boolean packed)
private void
writeBoolList_Internal(int fieldNumber, java.util.List<java.lang.Boolean> list, boolean packed)
void
writeBytesList(int fieldNumber, java.util.List<ByteString> list)
Writes a list field of typeFieldType.BYTES
.void
writeDouble(int fieldNumber, double value)
Writes a field of typeFieldType.DOUBLE
.void
writeDoubleList(int fieldNumber, java.util.List<java.lang.Double> list, boolean packed)
Writes a list field of typeFieldType.DOUBLE
.private void
writeDoubleList_Internal(int fieldNumber, DoubleArrayList list, boolean packed)
private void
writeDoubleList_Internal(int fieldNumber, java.util.List<java.lang.Double> list, boolean packed)
void
writeEnum(int fieldNumber, int value)
Writes a field of typeFieldType.ENUM
.void
writeEnumList(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.ENUM
.(package private) abstract void
writeFixed32(int value)
void
writeFixed32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.FIXED32
.private void
writeFixed32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
private void
writeFixed32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
(package private) abstract void
writeFixed64(long value)
void
writeFixed64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
Writes a list field of typeFieldType.FIXED64
.private void
writeFixed64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
private void
writeFixed64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
void
writeFloat(int fieldNumber, float value)
Writes a field of typeFieldType.FLOAT
.void
writeFloatList(int fieldNumber, java.util.List<java.lang.Float> list, boolean packed)
Writes a list field of typeFieldType.FLOAT
.private void
writeFloatList_Internal(int fieldNumber, FloatArrayList list, boolean packed)
private void
writeFloatList_Internal(int fieldNumber, java.util.List<java.lang.Float> list, boolean packed)
void
writeGroupList(int fieldNumber, java.util.List<?> list)
Writes a list field of typeFieldType.GROUP
.void
writeGroupList(int fieldNumber, java.util.List<?> list, Schema schema)
Writes a list field of typeFieldType.GROUP
.(package private) abstract void
writeInt32(int value)
void
writeInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.INT32
.private void
writeInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
private void
writeInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
void
writeInt64(int fieldNumber, long value)
Writes a field of typeFieldType.INT64
.void
writeInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
Writes a list field of typeFieldType.INT64
.private void
writeLazyString(int fieldNumber, java.lang.Object value)
<K,V>
voidwriteMap(int fieldNumber, MapEntryLite.Metadata<K,V> metadata, java.util.Map<K,V> map)
Writes a map field.(package private) static void
writeMapEntryField(Writer writer, int fieldNumber, WireFormat.FieldType fieldType, java.lang.Object object)
void
writeMessageList(int fieldNumber, java.util.List<?> list)
Writes a list field of typeFieldType.MESSAGE
.void
writeMessageList(int fieldNumber, java.util.List<?> list, Schema schema)
Writes a list field of typeFieldType.MESSAGE
.void
writeMessageSetItem(int fieldNumber, java.lang.Object value)
Writes a message field inMessageSet
wire-format.void
writeSFixed32(int fieldNumber, int value)
Writes a field of typeFieldType.SFIXED32
.void
writeSFixed32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.SFIXED32
.void
writeSFixed64(int fieldNumber, long value)
Writes a field of typeFieldType.SFIXED64
.void
writeSFixed64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
Writes a list field of typeFieldType.SFIXED64
.(package private) abstract void
writeSInt32(int value)
void
writeSInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.SINT32
.private void
writeSInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
private void
writeSInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
(package private) abstract void
writeSInt64(long value)
void
writeSInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
Writes a list field of typeFieldType.SINT64
.private void
writeSInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
private void
writeSInt64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
(package private) abstract void
writeString(java.lang.String in)
void
writeStringList(int fieldNumber, java.util.List<java.lang.String> list)
Writes a list field of typeFieldType.STRING
.(package private) abstract void
writeTag(int fieldNumber, int wireType)
void
writeUInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
Writes a list field of typeFieldType.UINT32
.private void
writeUInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed)
private void
writeUInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed)
void
writeUInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
Writes a list field of typeFieldType.UINT64
.private void
writeUInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed)
private void
writeUInt64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed)
(package private) abstract void
writeVarint32(int value)
(package private) abstract void
writeVarint64(long value)
-
Methods inherited from class com.google.protobuf.ByteOutput
write, write, write, writeLazy, writeLazy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.protobuf.Writer
writeBool, writeBytes, writeEndGroup, writeFixed32, writeFixed64, writeGroup, writeGroup, writeInt32, writeMessage, writeMessage, writeSInt32, writeSInt64, writeStartGroup, writeString, writeUInt32, writeUInt64
-
-
-
-
Field Detail
-
DEFAULT_CHUNK_SIZE
public static final int DEFAULT_CHUNK_SIZE
- See Also:
- Constant Field Values
-
alloc
private final BufferAllocator alloc
-
chunkSize
private final int chunkSize
-
buffers
final java.util.ArrayDeque<AllocatedBuffer> buffers
-
totalDoneBytes
int totalDoneBytes
-
MAP_KEY_NUMBER
private static final int MAP_KEY_NUMBER
- See Also:
- Constant Field Values
-
MAP_VALUE_NUMBER
private static final int MAP_VALUE_NUMBER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BinaryWriter
private BinaryWriter(BufferAllocator alloc, int chunkSize)
Only allow subclassing for inner classes.
-
-
Method Detail
-
newHeapInstance
public static BinaryWriter newHeapInstance(BufferAllocator alloc)
Creates a newBinaryWriter
that will allocate heap buffers ofDEFAULT_CHUNK_SIZE
as necessary.
-
newHeapInstance
public static BinaryWriter newHeapInstance(BufferAllocator alloc, int chunkSize)
Creates a newBinaryWriter
that will allocate heap buffers ofchunkSize
as necessary.
-
newDirectInstance
public static BinaryWriter newDirectInstance(BufferAllocator alloc)
Creates a newBinaryWriter
that will allocate direct (i.e. non-heap) buffers ofDEFAULT_CHUNK_SIZE
as necessary.
-
newDirectInstance
public static BinaryWriter newDirectInstance(BufferAllocator alloc, int chunkSize)
Creates a newBinaryWriter
that will allocate direct (i.e. non-heap) buffers ofchunkSize
as necessary.
-
isUnsafeHeapSupported
static boolean isUnsafeHeapSupported()
-
isUnsafeDirectSupported
static boolean isUnsafeDirectSupported()
-
newSafeHeapInstance
static BinaryWriter newSafeHeapInstance(BufferAllocator alloc, int chunkSize)
-
newUnsafeHeapInstance
static BinaryWriter newUnsafeHeapInstance(BufferAllocator alloc, int chunkSize)
-
newSafeDirectInstance
static BinaryWriter newSafeDirectInstance(BufferAllocator alloc, int chunkSize)
-
newUnsafeDirectInstance
static BinaryWriter newUnsafeDirectInstance(BufferAllocator alloc, int chunkSize)
-
fieldOrder
public final Writer.FieldOrder fieldOrder()
Description copied from interface:Writer
Indicates the order in which the fields are written by thisWriter
.- Specified by:
fieldOrder
in interfaceWriter
-
complete
public final java.util.Queue<AllocatedBuffer> complete()
Completes the write operation and returns a queue ofAllocatedBuffer
objects in forward-writing order. This method should only be called once.After calling this method, the writer can not be reused. Create a new writer for future writes.
-
writeSFixed32
public final void writeSFixed32(int fieldNumber, int value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.SFIXED32
.- Specified by:
writeSFixed32
in interfaceWriter
- Throws:
java.io.IOException
-
writeInt64
public final void writeInt64(int fieldNumber, long value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.INT64
.- Specified by:
writeInt64
in interfaceWriter
- Throws:
java.io.IOException
-
writeSFixed64
public final void writeSFixed64(int fieldNumber, long value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.SFIXED64
.- Specified by:
writeSFixed64
in interfaceWriter
- Throws:
java.io.IOException
-
writeFloat
public final void writeFloat(int fieldNumber, float value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.FLOAT
.- Specified by:
writeFloat
in interfaceWriter
- Throws:
java.io.IOException
-
writeDouble
public final void writeDouble(int fieldNumber, double value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.DOUBLE
.- Specified by:
writeDouble
in interfaceWriter
- Throws:
java.io.IOException
-
writeEnum
public final void writeEnum(int fieldNumber, int value) throws java.io.IOException
Description copied from interface:Writer
Writes a field of typeFieldType.ENUM
.
-
writeInt32List
public final void writeInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.INT32
.- Specified by:
writeInt32List
in interfaceWriter
- Throws:
java.io.IOException
-
writeInt32List_Internal
private final void writeInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeInt32List_Internal
private final void writeInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFixed32List
public final void writeFixed32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.FIXED32
.- Specified by:
writeFixed32List
in interfaceWriter
- Throws:
java.io.IOException
-
writeFixed32List_Internal
private final void writeFixed32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFixed32List_Internal
private final void writeFixed32List_Internal(int fieldNumber, IntArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeInt64List
public final void writeInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.INT64
.- Specified by:
writeInt64List
in interfaceWriter
- Throws:
java.io.IOException
-
writeUInt64List
public final void writeUInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.UINT64
.- Specified by:
writeUInt64List
in interfaceWriter
- Throws:
java.io.IOException
-
writeUInt64List_Internal
private final void writeUInt64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeUInt64List_Internal
private final void writeUInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFixed64List
public final void writeFixed64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.FIXED64
.- Specified by:
writeFixed64List
in interfaceWriter
- Throws:
java.io.IOException
-
writeFixed64List_Internal
private final void writeFixed64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFixed64List_Internal
private final void writeFixed64List_Internal(int fieldNumber, LongArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFloatList
public final void writeFloatList(int fieldNumber, java.util.List<java.lang.Float> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.FLOAT
.- Specified by:
writeFloatList
in interfaceWriter
- Throws:
java.io.IOException
-
writeFloatList_Internal
private final void writeFloatList_Internal(int fieldNumber, java.util.List<java.lang.Float> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFloatList_Internal
private final void writeFloatList_Internal(int fieldNumber, FloatArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDoubleList
public final void writeDoubleList(int fieldNumber, java.util.List<java.lang.Double> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.DOUBLE
.- Specified by:
writeDoubleList
in interfaceWriter
- Throws:
java.io.IOException
-
writeDoubleList_Internal
private final void writeDoubleList_Internal(int fieldNumber, java.util.List<java.lang.Double> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDoubleList_Internal
private final void writeDoubleList_Internal(int fieldNumber, DoubleArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEnumList
public final void writeEnumList(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.ENUM
.- Specified by:
writeEnumList
in interfaceWriter
- Throws:
java.io.IOException
-
writeBoolList
public final void writeBoolList(int fieldNumber, java.util.List<java.lang.Boolean> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.BOOL
.- Specified by:
writeBoolList
in interfaceWriter
- Throws:
java.io.IOException
-
writeBoolList_Internal
private final void writeBoolList_Internal(int fieldNumber, java.util.List<java.lang.Boolean> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBoolList_Internal
private final void writeBoolList_Internal(int fieldNumber, BooleanArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringList
public final void writeStringList(int fieldNumber, java.util.List<java.lang.String> list) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.STRING
.- Specified by:
writeStringList
in interfaceWriter
- Throws:
java.io.IOException
-
writeLazyString
private void writeLazyString(int fieldNumber, java.lang.Object value) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBytesList
public final void writeBytesList(int fieldNumber, java.util.List<ByteString> list) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.BYTES
.- Specified by:
writeBytesList
in interfaceWriter
- Throws:
java.io.IOException
-
writeUInt32List
public final void writeUInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.UINT32
.- Specified by:
writeUInt32List
in interfaceWriter
- Throws:
java.io.IOException
-
writeUInt32List_Internal
private final void writeUInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeUInt32List_Internal
private final void writeUInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSFixed32List
public final void writeSFixed32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.SFIXED32
.- Specified by:
writeSFixed32List
in interfaceWriter
- Throws:
java.io.IOException
-
writeSFixed64List
public final void writeSFixed64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.SFIXED64
.- Specified by:
writeSFixed64List
in interfaceWriter
- Throws:
java.io.IOException
-
writeSInt32List
public final void writeSInt32List(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.SINT32
.- Specified by:
writeSInt32List
in interfaceWriter
- Throws:
java.io.IOException
-
writeSInt32List_Internal
private final void writeSInt32List_Internal(int fieldNumber, java.util.List<java.lang.Integer> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSInt32List_Internal
private final void writeSInt32List_Internal(int fieldNumber, IntArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSInt64List
public final void writeSInt64List(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.SINT64
.- Specified by:
writeSInt64List
in interfaceWriter
- Throws:
java.io.IOException
-
writeMap
public <K,V> void writeMap(int fieldNumber, MapEntryLite.Metadata<K,V> metadata, java.util.Map<K,V> map) throws java.io.IOException
Description copied from interface:Writer
Writes a map field.
-
writeMapEntryField
static final void writeMapEntryField(Writer writer, int fieldNumber, WireFormat.FieldType fieldType, java.lang.Object object) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSInt64List_Internal
private final void writeSInt64List_Internal(int fieldNumber, java.util.List<java.lang.Long> list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSInt64List_Internal
private final void writeSInt64List_Internal(int fieldNumber, LongArrayList list, boolean packed) throws java.io.IOException
- Throws:
java.io.IOException
-
writeMessageList
public final void writeMessageList(int fieldNumber, java.util.List<?> list) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.MESSAGE
.- Specified by:
writeMessageList
in interfaceWriter
- Throws:
java.io.IOException
-
writeMessageList
public final void writeMessageList(int fieldNumber, java.util.List<?> list, Schema schema) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.MESSAGE
.- Specified by:
writeMessageList
in interfaceWriter
- Throws:
java.io.IOException
-
writeGroupList
public final void writeGroupList(int fieldNumber, java.util.List<?> list) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.GROUP
.- Specified by:
writeGroupList
in interfaceWriter
- Throws:
java.io.IOException
-
writeGroupList
public final void writeGroupList(int fieldNumber, java.util.List<?> list, Schema schema) throws java.io.IOException
Description copied from interface:Writer
Writes a list field of typeFieldType.GROUP
.- Specified by:
writeGroupList
in interfaceWriter
- Throws:
java.io.IOException
-
writeMessageSetItem
public final void writeMessageSetItem(int fieldNumber, java.lang.Object value) throws java.io.IOException
Description copied from interface:Writer
Writes a message field inMessageSet
wire-format.- Specified by:
writeMessageSetItem
in interfaceWriter
value
- A message instance or an opaqueByteString
for an unknown field.- Throws:
java.io.IOException
-
newHeapBuffer
final AllocatedBuffer newHeapBuffer()
-
newHeapBuffer
final AllocatedBuffer newHeapBuffer(int capacity)
-
newDirectBuffer
final AllocatedBuffer newDirectBuffer()
-
newDirectBuffer
final AllocatedBuffer newDirectBuffer(int capacity)
-
getTotalBytesWritten
public abstract int getTotalBytesWritten()
Gets the total number of bytes that have been written. This will not be reset by a call tocomplete()
.
-
requireSpace
abstract void requireSpace(int size)
-
finishCurrentBuffer
abstract void finishCurrentBuffer()
-
writeTag
abstract void writeTag(int fieldNumber, int wireType)
-
writeVarint32
abstract void writeVarint32(int value)
-
writeInt32
abstract void writeInt32(int value)
-
writeSInt32
abstract void writeSInt32(int value)
-
writeFixed32
abstract void writeFixed32(int value)
-
writeVarint64
abstract void writeVarint64(long value)
-
writeSInt64
abstract void writeSInt64(long value)
-
writeFixed64
abstract void writeFixed64(long value)
-
writeBool
abstract void writeBool(boolean value)
-
writeString
abstract void writeString(java.lang.String in)
-
computeUInt64SizeNoTag
private static byte computeUInt64SizeNoTag(long value)
Not using the version in CodedOutputStream due to the fact that benchmarks have shown a performance improvement when returning a byte (rather than an int).
-
-