Class DataCellSerialization

  • All Implemented Interfaces:
    CellInput, java.io.Closeable, java.io.DataInput, java.io.Flushable, java.lang.AutoCloseable

    final class DataCellSerialization
    extends java.io.ByteArrayOutputStream
    implements CellInput
    An object that manages the serialization and deserialization of objects to the database file system. This object maintains a buffer that stores intermediate serialization information as objects are written.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private char[] char_buffer  
      private byte[] compress_buf  
      private int compress_length  
      private java.util.zip.Deflater deflater
      A Deflater and Inflater used to compress and uncompress the size of data fields put into the store.
      private static ByteLongObject EMPTY_BYTE_LONG_OBJECT
      A 0 size ByteLongObject object.
      private java.util.zip.Inflater inflater  
      private boolean is_null
      Set to true if null.
      private short type
      The type of object.
      private boolean use_compressed
      If true, when writing out use the compressed form.
      • Fields inherited from class java.io.ByteArrayOutputStream

        buf, count
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      private BigNumber createBigNumber​(byte[] buf, int scale, byte state)
      Creates a BigNumber object used to store a numeric value in the database.
      void mark​(int readAheadLimit)  
      int read()  
      int read​(byte[] b, int off, int len)  
      boolean readBoolean()  
      byte readByte()  
      char readChar()  
      java.lang.String readChars​(int length)
      Reads a string of chars from the input stream up to the given length and returns it as a String object.
      double readDouble()  
      float readFloat()  
      private java.lang.Object readFromCellInput​(CellInput din)
      Reads an object from the given CellInput.
      void readFully​(byte[] b)  
      void readFully​(byte[] b, int off, int len)  
      int readInt()  
      java.lang.String readLine()  
      long readLong()  
      (package private) java.lang.Object readSerialization​(CellInput din)
      Reads input from the given CellInput object.
      short readShort()  
      int readUnsignedByte()  
      int readUnsignedShort()  
      java.lang.String readUTF()  
      (package private) void setToSerialize​(TObject cell)
      Sets this up with a TObject to serialize.
      long skip​(long n)  
      int skipBytes​(int n)  
      (package private) int skipSerialization​(CellInput din)
      Returns the number of bytes to skip on the stream to go past the next serialization.
      void writeBoolean​(boolean v)  
      void writeByte​(int v)  
      void writeChar​(int v)  
      void writeChars​(java.lang.String s)  
      void writeInt​(int v)  
      void writeLong​(long v)  
      (package private) void writeSerialization​(java.io.DataOutputStream out)
      Writes the current serialized data buffer to the output stream.
      void writeShort​(int v)  
      private void writeToBuffer​(TObject cell)
      Writes the TObject to the data buffer in this object.
      • Methods inherited from class java.io.ByteArrayOutputStream

        reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeTo
      • Methods inherited from class java.io.OutputStream

        flush, nullOutputStream, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • deflater

        private java.util.zip.Deflater deflater
        A Deflater and Inflater used to compress and uncompress the size of data fields put into the store.
      • inflater

        private java.util.zip.Inflater inflater
      • compress_buf

        private byte[] compress_buf
      • compress_length

        private int compress_length
      • use_compressed

        private boolean use_compressed
        If true, when writing out use the compressed form.
      • type

        private short type
        The type of object.
      • is_null

        private boolean is_null
        Set to true if null.
      • char_buffer

        private char[] char_buffer
      • EMPTY_BYTE_LONG_OBJECT

        private static final ByteLongObject EMPTY_BYTE_LONG_OBJECT
        A 0 size ByteLongObject object.
    • Constructor Detail

      • DataCellSerialization

        DataCellSerialization()
        Constructor.
    • Method Detail

      • skipSerialization

        int skipSerialization​(CellInput din)
                       throws java.io.IOException
        Returns the number of bytes to skip on the stream to go past the next serialization.
        Throws:
        java.io.IOException
      • readSerialization

        java.lang.Object readSerialization​(CellInput din)
                                    throws java.io.IOException
        Reads input from the given CellInput object.
        Throws:
        java.io.IOException
      • createBigNumber

        private BigNumber createBigNumber​(byte[] buf,
                                          int scale,
                                          byte state)
        Creates a BigNumber object used to store a numeric value in the database.
      • readFromCellInput

        private java.lang.Object readFromCellInput​(CellInput din)
                                            throws java.io.IOException
        Reads an object from the given CellInput. No type information is included with the returned object so it must be wrapped in a TObject. Returns null if the object stored was null.
        Throws:
        java.io.IOException
      • writeSerialization

        void writeSerialization​(java.io.DataOutputStream out)
                         throws java.io.IOException
        Writes the current serialized data buffer to the output stream.
        Throws:
        java.io.IOException
      • setToSerialize

        void setToSerialize​(TObject cell)
                     throws java.io.IOException
        Sets this up with a TObject to serialize.
        Throws:
        java.io.IOException
      • writeToBuffer

        private void writeToBuffer​(TObject cell)
                            throws java.io.IOException
        Writes the TObject to the data buffer in this object.
        Throws:
        java.io.IOException
      • writeBoolean

        public final void writeBoolean​(boolean v)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeByte

        public final void writeByte​(int v)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeShort

        public final void writeShort​(int v)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeChar

        public final void writeChar​(int v)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeInt

        public final void writeInt​(int v)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLong

        public final void writeLong​(long v)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeChars

        public final void writeChars​(java.lang.String s)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • mark

        public void mark​(int readAheadLimit)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.ByteArrayOutputStream
        Throws:
        java.io.IOException
      • readFully

        public void readFully​(byte[] b)
                       throws java.io.IOException
        Specified by:
        readFully in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readFully

        public void readFully​(byte[] b,
                              int off,
                              int len)
                       throws java.io.IOException
        Specified by:
        readFully in interface java.io.DataInput
        Throws:
        java.io.IOException
      • skipBytes

        public int skipBytes​(int n)
                      throws java.io.IOException
        Specified by:
        skipBytes in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readBoolean

        public boolean readBoolean()
                            throws java.io.IOException
        Specified by:
        readBoolean in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readByte

        public byte readByte()
                      throws java.io.IOException
        Specified by:
        readByte in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readUnsignedByte

        public int readUnsignedByte()
                             throws java.io.IOException
        Specified by:
        readUnsignedByte in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readShort

        public short readShort()
                        throws java.io.IOException
        Specified by:
        readShort in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readUnsignedShort

        public int readUnsignedShort()
                              throws java.io.IOException
        Specified by:
        readUnsignedShort in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readChar

        public char readChar()
                      throws java.io.IOException
        Specified by:
        readChar in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readChars

        public java.lang.String readChars​(int length)
                                   throws java.io.IOException
        Description copied from interface: CellInput
        Reads a string of chars from the input stream up to the given length and returns it as a String object.
        Specified by:
        readChars in interface CellInput
        Throws:
        java.io.IOException
      • readInt

        public int readInt()
                    throws java.io.IOException
        Specified by:
        readInt in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readLong

        public long readLong()
                      throws java.io.IOException
        Specified by:
        readLong in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readFloat

        public float readFloat()
                        throws java.io.IOException
        Specified by:
        readFloat in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readDouble

        public double readDouble()
                          throws java.io.IOException
        Specified by:
        readDouble in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readLine

        public java.lang.String readLine()
                                  throws java.io.IOException
        Specified by:
        readLine in interface java.io.DataInput
        Throws:
        java.io.IOException
      • readUTF

        public java.lang.String readUTF()
                                 throws java.io.IOException
        Specified by:
        readUTF in interface java.io.DataInput
        Throws:
        java.io.IOException