Package io.protostuff
Class LowCopyProtostuffOutput
- java.lang.Object
-
- io.protostuff.LowCopyProtostuffOutput
-
- All Implemented Interfaces:
Output
public final class LowCopyProtostuffOutput extends java.lang.Object implements Output
Output that differs from the standard by attempting to avoid extra copies of large ByteBuffer fields. When used with ByteBuffer=true compiler option, we can splice in ByteBuffer objects without copying them. Most of the magic lives in LinkBuffer, so this class exists just to serialize to a LinkBuffer.
-
-
Field Summary
Fields Modifier and Type Field Description LinkBuffer
buffer
-
Constructor Summary
Constructors Constructor Description LowCopyProtostuffOutput()
LowCopyProtostuffOutput(LinkBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
writeBool(int fieldNumber, boolean value, boolean repeated)
Writes a boolean field.void
writeByteArray(int fieldNumber, byte[] bytes, boolean repeated)
Writes a byte array field.void
writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated)
Writes a binary or a pre-encoded utf8 string.void
writeBytes(int fieldNumber, ByteString value, boolean repeated)
Writes a ByteString(wraps byte array) field.void
writeBytes(int fieldNumber, java.nio.ByteBuffer value, boolean repeated)
void
writeDouble(int fieldNumber, double value, boolean repeated)
Writes a double field.void
writeEnum(int fieldNumber, int number, boolean repeated)
Writes a enum(its number) field.void
writeFixed32(int fieldNumber, int value, boolean repeated)
Writes a fixed int(4 bytes) field.void
writeFixed64(int fieldNumber, long value, boolean repeated)
Writes a fixed long(8 bytes) field.void
writeFloat(int fieldNumber, float value, boolean repeated)
Writes a float field.void
writeInt32(int fieldNumber, int value, boolean repeated)
Writes a variable int field.void
writeInt64(int fieldNumber, long value, boolean repeated)
Writes a variable long field.<T> void
writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated)
Writes an object(using its schema) field.void
writeSFixed32(int fieldNumber, int value, boolean repeated)
Writes a signed+fixed int(4 bytes) field.void
writeSFixed64(int fieldNumber, long value, boolean repeated)
Writes a signed+fixed long(8 bytes) field.void
writeSInt32(int fieldNumber, int value, boolean repeated)
Writes a signed int field.void
writeSInt64(int fieldNumber, long value, boolean repeated)
Writes a signed long field.void
writeString(int fieldNumber, java.lang.CharSequence value, boolean repeated)
Writes a String field.void
writeUInt32(int fieldNumber, int value, boolean repeated)
Writes an unsigned int field.void
writeUInt64(int fieldNumber, long value, boolean repeated)
Writes an unsigned long field.
-
-
-
Field Detail
-
buffer
public LinkBuffer buffer
-
-
Constructor Detail
-
LowCopyProtostuffOutput
public LowCopyProtostuffOutput()
-
LowCopyProtostuffOutput
public LowCopyProtostuffOutput(LinkBuffer buffer)
-
-
Method Detail
-
writeInt32
public void writeInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a variable int field.- Specified by:
writeInt32
in interfaceOutput
- Throws:
java.io.IOException
-
writeUInt32
public void writeUInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes an unsigned int field.- Specified by:
writeUInt32
in interfaceOutput
- Throws:
java.io.IOException
-
writeSInt32
public void writeSInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a signed int field.- Specified by:
writeSInt32
in interfaceOutput
- Throws:
java.io.IOException
-
writeFixed32
public void writeFixed32(int fieldNumber, int value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a fixed int(4 bytes) field.- Specified by:
writeFixed32
in interfaceOutput
- Throws:
java.io.IOException
-
writeSFixed32
public void writeSFixed32(int fieldNumber, int value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a signed+fixed int(4 bytes) field.- Specified by:
writeSFixed32
in interfaceOutput
- Throws:
java.io.IOException
-
writeInt64
public void writeInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a variable long field.- Specified by:
writeInt64
in interfaceOutput
- Throws:
java.io.IOException
-
writeUInt64
public void writeUInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes an unsigned long field.- Specified by:
writeUInt64
in interfaceOutput
- Throws:
java.io.IOException
-
writeSInt64
public void writeSInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a signed long field.- Specified by:
writeSInt64
in interfaceOutput
- Throws:
java.io.IOException
-
writeFixed64
public void writeFixed64(int fieldNumber, long value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a fixed long(8 bytes) field.- Specified by:
writeFixed64
in interfaceOutput
- Throws:
java.io.IOException
-
writeSFixed64
public void writeSFixed64(int fieldNumber, long value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a signed+fixed long(8 bytes) field.- Specified by:
writeSFixed64
in interfaceOutput
- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(int fieldNumber, float value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a float field.- Specified by:
writeFloat
in interfaceOutput
- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(int fieldNumber, double value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a double field.- Specified by:
writeDouble
in interfaceOutput
- Throws:
java.io.IOException
-
writeBool
public void writeBool(int fieldNumber, boolean value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a boolean field.
-
writeEnum
public void writeEnum(int fieldNumber, int number, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a enum(its number) field.
-
writeString
public void writeString(int fieldNumber, java.lang.CharSequence value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a String field.- Specified by:
writeString
in interfaceOutput
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(int fieldNumber, ByteString value, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a ByteString(wraps byte array) field.- Specified by:
writeBytes
in interfaceOutput
- Throws:
java.io.IOException
-
writeByteArray
public void writeByteArray(int fieldNumber, byte[] bytes, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a byte array field.- Specified by:
writeByteArray
in interfaceOutput
- Throws:
java.io.IOException
-
writeByteRange
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes a binary or a pre-encoded utf8 string.- Specified by:
writeByteRange
in interfaceOutput
- Throws:
java.io.IOException
-
writeObject
public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws java.io.IOException
Description copied from interface:Output
Writes an object(using its schema) field.- Specified by:
writeObject
in interfaceOutput
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(int fieldNumber, java.nio.ByteBuffer value, boolean repeated) throws java.io.IOException
- Specified by:
writeBytes
in interfaceOutput
- Throws:
java.io.IOException
-
-