Class RegularDataEncoder

  • Direct Known Subclasses:
    RegularDataEncoder.IntRegularEncoder, RegularDataEncoder.LongRegularEncoder

    public abstract class RegularDataEncoder
    extends Encoder
    RegularDataEncoder is an encoder for compressing data in type of integer and long. We adapt a hypothesis that the difference between each data point is the same, which it means the data is regular.

    To encode the regular data, we first create an array as a block to store the data loaded into the encoder. While it reach the default block size, start calculating the delta between each data point in this block in order to checkout whether there are missing points exist in the data. If there is, create a bitmap for this block to denote the position of missing points. Next, store the data info (the data size, the minimum delta value and the first data point of this block) and the bitmap with its info into the result byte array output stream.

    • Field Detail

      • out

        protected java.io.ByteArrayOutputStream out
      • blockSize

        protected int blockSize
      • isMissingPoint

        protected boolean isMissingPoint
      • writeIndex

        protected int writeIndex
      • dataTotal

        protected int dataTotal
    • Constructor Detail

      • RegularDataEncoder

        protected RegularDataEncoder​(int size)
        constructor of RegularDataEncoder.
        Parameters:
        size - - the number how many numbers to be packed into a block.
    • Method Detail

      • writeHeader

        protected abstract void writeHeader()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • reset

        protected abstract void reset()
      • checkMissingPoint

        protected abstract void checkMissingPoint​(java.io.ByteArrayOutputStream out)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBitmap

        protected abstract void writeBitmap​(java.io.ByteArrayOutputStream out)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeHeaderToBytes

        protected void writeHeaderToBytes()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • flushBlockBuffer

        protected void flushBlockBuffer​(java.io.ByteArrayOutputStream out)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • flush

        public void flush​(java.io.ByteArrayOutputStream out)
        calling this method to flush all values which haven't encoded to result byte array.
        Specified by:
        flush in class Encoder
        Parameters:
        out - - ByteArrayOutputStream