Package com.google.protobuf
Class BinaryWriter.UnsafeDirectWriter
java.lang.Object
com.google.protobuf.ByteOutput
com.google.protobuf.BinaryWriter
com.google.protobuf.BinaryWriter.UnsafeDirectWriter
- All Implemented Interfaces:
Writer
- Enclosing class:
- BinaryWriter
Writer that uses unsafe operations on a target
ByteBuffer.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.protobuf.Writer
Writer.FieldOrder -
Field Summary
FieldsFields inherited from class com.google.protobuf.BinaryWriter
buffers, DEFAULT_CHUNK_SIZE, totalDoneBytes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intprivate int(package private) voidintGets the total number of bytes that have been written.private static booleanIndicates whether the required unsafe operations are supported on this platform.private voidprivate voidnextBuffer(int capacity) private voidnextBuffer(AllocatedBuffer allocatedBuffer) (package private) voidrequireSpace(int size) private intvoidwrite(byte value) Writes a single byte.voidwrite(byte[] value, int offset, int length) Writes a sequence of bytes.voidwrite(ByteBuffer value) Writes a sequence of bytes.(package private) voidwriteBool(boolean value) voidwriteBool(int fieldNumber, boolean value) Writes a field of typeFieldType.BOOL.voidwriteBytes(int fieldNumber, ByteString value) Writes a field of typeFieldType.BYTES.voidwriteEndGroup(int fieldNumber) Deprecated.(package private) voidwriteFixed32(int value) voidwriteFixed32(int fieldNumber, int value) Writes a field of typeFieldType.FIXED32.voidwriteFixed64(int fieldNumber, long value) Writes a field of typeFieldType.FIXED64.(package private) voidwriteFixed64(long value) voidwriteGroup(int fieldNumber, Object value) Writes a field of typeFieldType.GROUP.voidwriteGroup(int fieldNumber, Object value, Schema schema) Writes a field of typeFieldType.GROUP.(package private) voidwriteInt32(int value) voidwriteInt32(int fieldNumber, int value) Writes a field of typeFieldType.INT32.voidwriteLazy(byte[] value, int offset, int length) Writes a sequence of bytes.voidwriteLazy(ByteBuffer value) Writes a sequence of bytes.voidwriteMessage(int fieldNumber, Object value) Writes a field of typeFieldType.MESSAGE.voidwriteMessage(int fieldNumber, Object value, Schema schema) Writes a field of typeFieldType.MESSAGE.(package private) voidwriteSInt32(int value) voidwriteSInt32(int fieldNumber, int value) Writes a field of typeFieldType.SINT32.voidwriteSInt64(int fieldNumber, long value) Writes a field of typeFieldType.SINT64.(package private) voidwriteSInt64(long value) voidwriteStartGroup(int fieldNumber) Deprecated.voidwriteString(int fieldNumber, String value) Writes a field of typeFieldType.STRING.(package private) voidwriteString(String in) (package private) voidwriteTag(int fieldNumber, int wireType) voidwriteUInt32(int fieldNumber, int value) Writes a field of typeFieldType.UINT32.voidwriteUInt64(int fieldNumber, long value) Writes a field of typeFieldType.UINT64.(package private) voidwriteVarint32(int value) private voidwriteVarint32FiveBytes(int value) private voidwriteVarint32FourBytes(int value) private voidwriteVarint32OneByte(int value) private voidwriteVarint32ThreeBytes(int value) private voidwriteVarint32TwoBytes(int value) (package private) voidwriteVarint64(long value) private voidwriteVarint64EightBytes(long value) private voidwriteVarint64FiveBytes(long value) private voidwriteVarint64FourBytes(long value) private voidwriteVarint64NineBytes(long value) private voidwriteVarint64OneByte(long value) private voidwriteVarint64SevenBytes(long value) private voidwriteVarint64SixBytes(long value) private voidwriteVarint64TenBytes(long value) private voidwriteVarint64ThreeBytes(long value) private voidwriteVarint64TwoBytes(long value) Methods inherited from class com.google.protobuf.BinaryWriter
complete, fieldOrder, isUnsafeDirectSupported, isUnsafeHeapSupported, newDirectBuffer, newDirectBuffer, newDirectInstance, newDirectInstance, newHeapBuffer, newHeapBuffer, newHeapInstance, newHeapInstance, newSafeDirectInstance, newSafeHeapInstance, newUnsafeDirectInstance, newUnsafeHeapInstance, writeBoolList, writeBytesList, writeDouble, writeDoubleList, writeEnum, writeEnumList, writeFixed32List, writeFixed64List, writeFloat, writeFloatList, writeGroupList, writeGroupList, writeInt32List, writeInt64, writeInt64List, writeMap, writeMapEntryField, writeMessageList, writeMessageList, writeMessageSetItem, writeSFixed32, writeSFixed32List, writeSFixed64, writeSFixed64List, writeSInt32List, writeSInt64List, writeStringList, writeUInt32List, writeUInt64List
-
Field Details
-
buffer
-
bufferOffset
private long bufferOffset -
limitMinusOne
private long limitMinusOne -
pos
private long pos
-
-
Constructor Details
-
UnsafeDirectWriter
UnsafeDirectWriter(BufferAllocator alloc, int chunkSize)
-
-
Method Details
-
isSupported
private static boolean isSupported()Indicates whether the required unsafe operations are supported on this platform. -
nextBuffer
private void nextBuffer() -
nextBuffer
private void nextBuffer(int capacity) -
nextBuffer
-
getTotalBytesWritten
public int getTotalBytesWritten()Description copied from class:BinaryWriterGets the total number of bytes that have been written. This will not be reset by a call toBinaryWriter.complete().- Specified by:
getTotalBytesWrittenin classBinaryWriter
-
bytesWrittenToCurrentBuffer
private int bytesWrittenToCurrentBuffer() -
spaceLeft
private int spaceLeft() -
finishCurrentBuffer
void finishCurrentBuffer()- Specified by:
finishCurrentBufferin classBinaryWriter
-
bufferPos
private int bufferPos() -
writeUInt32
public void writeUInt32(int fieldNumber, int value) Description copied from interface:WriterWrites a field of typeFieldType.UINT32. -
writeInt32
public void writeInt32(int fieldNumber, int value) Description copied from interface:WriterWrites a field of typeFieldType.INT32. -
writeSInt32
public void writeSInt32(int fieldNumber, int value) Description copied from interface:WriterWrites a field of typeFieldType.SINT32. -
writeFixed32
public void writeFixed32(int fieldNumber, int value) Description copied from interface:WriterWrites a field of typeFieldType.FIXED32. -
writeUInt64
public void writeUInt64(int fieldNumber, long value) Description copied from interface:WriterWrites a field of typeFieldType.UINT64. -
writeSInt64
public void writeSInt64(int fieldNumber, long value) Description copied from interface:WriterWrites a field of typeFieldType.SINT64. -
writeFixed64
public void writeFixed64(int fieldNumber, long value) Description copied from interface:WriterWrites a field of typeFieldType.FIXED64. -
writeBool
public void writeBool(int fieldNumber, boolean value) Description copied from interface:WriterWrites a field of typeFieldType.BOOL. -
writeString
Description copied from interface:WriterWrites a field of typeFieldType.STRING. -
writeBytes
Description copied from interface:WriterWrites a field of typeFieldType.BYTES. -
writeMessage
Description copied from interface:WriterWrites a field of typeFieldType.MESSAGE.- Throws:
IOException
-
writeMessage
Description copied from interface:WriterWrites a field of typeFieldType.MESSAGE.- Throws:
IOException
-
writeGroup
Description copied from interface:WriterWrites a field of typeFieldType.GROUP.- Throws:
IOException
-
writeGroup
Description copied from interface:WriterWrites a field of typeFieldType.GROUP.- Throws:
IOException
-
writeStartGroup
Deprecated.Description copied from interface:WriterWrites a single start group tag. -
writeEndGroup
Deprecated.Description copied from interface:WriterWrites a single end group tag. -
writeInt32
void writeInt32(int value) - Specified by:
writeInt32in classBinaryWriter
-
writeSInt32
void writeSInt32(int value) - Specified by:
writeSInt32in classBinaryWriter
-
writeSInt64
void writeSInt64(long value) - Specified by:
writeSInt64in classBinaryWriter
-
writeBool
void writeBool(boolean value) - Specified by:
writeBoolin classBinaryWriter
-
writeTag
void writeTag(int fieldNumber, int wireType) - Specified by:
writeTagin classBinaryWriter
-
writeVarint32
void writeVarint32(int value) - Specified by:
writeVarint32in classBinaryWriter
-
writeVarint32OneByte
private void writeVarint32OneByte(int value) -
writeVarint32TwoBytes
private void writeVarint32TwoBytes(int value) -
writeVarint32ThreeBytes
private void writeVarint32ThreeBytes(int value) -
writeVarint32FourBytes
private void writeVarint32FourBytes(int value) -
writeVarint32FiveBytes
private void writeVarint32FiveBytes(int value) -
writeVarint64
void writeVarint64(long value) - Specified by:
writeVarint64in classBinaryWriter
-
writeVarint64OneByte
private void writeVarint64OneByte(long value) -
writeVarint64TwoBytes
private void writeVarint64TwoBytes(long value) -
writeVarint64ThreeBytes
private void writeVarint64ThreeBytes(long value) -
writeVarint64FourBytes
private void writeVarint64FourBytes(long value) -
writeVarint64FiveBytes
private void writeVarint64FiveBytes(long value) -
writeVarint64SixBytes
private void writeVarint64SixBytes(long value) -
writeVarint64SevenBytes
private void writeVarint64SevenBytes(long value) -
writeVarint64EightBytes
private void writeVarint64EightBytes(long value) -
writeVarint64NineBytes
private void writeVarint64NineBytes(long value) -
writeVarint64TenBytes
private void writeVarint64TenBytes(long value) -
writeFixed32
void writeFixed32(int value) - Specified by:
writeFixed32in classBinaryWriter
-
writeFixed64
void writeFixed64(long value) - Specified by:
writeFixed64in classBinaryWriter
-
writeString
- Specified by:
writeStringin classBinaryWriter
-
write
public void write(byte value) Description copied from class:ByteOutputWrites a single byte.- Specified by:
writein classByteOutput- Parameters:
value- the byte to be written
-
write
public void write(byte[] value, int offset, int length) Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay be reused/altered by the caller.NOTE: This method MUST NOT modify the
value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.- Specified by:
writein classByteOutput- Parameters:
value- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset
-
writeLazy
public void writeLazy(byte[] value, int offset, int length) Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputis free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.NOTE: This method MUST NOT modify the
value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.- Specified by:
writeLazyin classByteOutput- Parameters:
value- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset
-
write
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay be reused/altered by the caller.NOTE: This method MUST NOT modify the
value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.- Specified by:
writein classByteOutput- Parameters:
value- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit
-
writeLazy
Description copied from class:ByteOutputWrites a sequence of bytes. TheByteOutputis free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.NOTE: This method MUST NOT modify the
value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.- Specified by:
writeLazyin classByteOutput- Parameters:
value- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit
-
requireSpace
void requireSpace(int size) - Specified by:
requireSpacein classBinaryWriter
-