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 Detail

      • BitmapEncoder

        public BitmapEncoder()
        BitmapEncoder constructor.
    • Method Detail

      • encode

        public void encode​(int value,
                           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:
        IOException - cannot encode value
        See Also:
        Encoder.encode(int, 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