Class ProtobufRecord

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ProtobufRecord
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A protobuf record, storing the WireType, the parsed field number, and the bytes for it.
    Since:
    17862
    • Constructor Detail

      • ProtobufRecord

        public ProtobufRecord​(java.io.ByteArrayOutputStream byteArrayOutputStream,
                              ProtobufParser parser)
                       throws java.io.IOException
        Create a new Protobuf record
        Parameters:
        byteArrayOutputStream - A reusable ByteArrayOutputStream to avoid unnecessary allocations
        parser - The parser to use to create the record
        Throws:
        java.io.IOException - - if an IO error occurs
    • Method Detail

      • asSignedVarInt

        public java.lang.Number asSignedVarInt()
        Get the signed var int (WireType#VARINT). These are specially encoded so that they take up less space.
        Returns:
        The signed var int (sint32 or sint64)
      • asUnsignedVarInt

        public java.lang.Number asUnsignedVarInt()
        Get the var int (WireType#VARINT)
        Returns:
        The var int (int32, int64, uint32, uint64, bool, enum)
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • getBytes

        public byte[] getBytes()
        Get the raw bytes for this record
        Returns:
        The bytes
      • getField

        public int getField()
        Get the field value
        Returns:
        The field value