Class BitmapEncoder


  • public class BitmapEncoder
    extends Encoder
    Encodes values using bitmap, according to the following grammar:
    
     bitmap-encoding: <length> <num> <encoded-data>
     length := length of the <encoded-data> in bytes stored as unsigned var int
     num := number for all encoded data in <encoded-data> stored as unsigned var int
     encoded-data := <run>*
     run := <value> <bit-index>
     value := value in the data after deduplication. Use varint-encode and store as unsigned var int
     bit-index := a list of 01 sequence to record the position of the value above
     

    Decode switch or enum values using bitmap, bitmap-encode.<length> <num> <encoded data>

    • Constructor Summary

      Constructors 
      Constructor Description
      BitmapEncoder()
      BitmapEncoder constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void encode​(int value, java.io.ByteArrayOutputStream out)
      Each time encoder receives a value, encoder doesn't write it to OutputStream immediately.
      void flush​(java.io.ByteArrayOutputStream out)
      When all data received, encoder now encodes values in list and write them to OutputStream.
      long getMaxByteSize()
      The maximal possible memory size occupied by current Encoder.
      int getOneItemMaxSize()
      When encoder accepts a new incoming data point, the maximal possible size in byte it takes to store in memory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BitmapEncoder

        public BitmapEncoder()
        BitmapEncoder constructor.
    • Method Detail

      • encode

        public void encode​(int value,
                           java.io.ByteArrayOutputStream out)
        Each time encoder receives a value, encoder doesn't write it to OutputStream immediately. Encoder stores current value in a list. When all value is received, flush() method will be invoked. Encoder encodes all values and writes them to OutputStream.
        Overrides:
        encode in class Encoder
        Parameters:
        value - value to encode
        out - OutputStream to write encoded stream
        Throws:
        java.io.IOException - cannot encode value
        See Also:
        Encoder.encode(int, java.io.ByteArrayOutputStream)
      • flush

        public void flush​(java.io.ByteArrayOutputStream out)
                   throws java.io.IOException
        When all data received, encoder now encodes values in list and write them to OutputStream.
        Specified by:
        flush in class Encoder
        Parameters:
        out - OutputStream to write encoded stream
        Throws:
        java.io.IOException - cannot flush to OutputStream
        See Also:
        Encoder.flush(java.io.ByteArrayOutputStream)
      • getOneItemMaxSize

        public int getOneItemMaxSize()
        Description copied from class: Encoder
        When encoder accepts a new incoming data point, the maximal possible size in byte it takes to store in memory.
        Overrides:
        getOneItemMaxSize in class Encoder
        Returns:
        the maximal possible size of one data item encoded by this encoder
      • getMaxByteSize

        public long getMaxByteSize()
        Description copied from class: Encoder
        The maximal possible memory size occupied by current Encoder. This statistic value doesn't involve OutputStream.
        Overrides:
        getMaxByteSize in class Encoder
        Returns:
        the maximal size of possible memory occupied by current encoder