org.apache.lucene.facet.encoding

## Class FourFlagsIntEncoder

- java.lang.Object
- - org.apache.lucene.facet.encoding.IntEncoder
  - - org.apache.lucene.facet.encoding.ChunksIntEncoder
    - - org.apache.lucene.facet.encoding.FourFlagsIntEncoder

- Direct Known Subclasses:
    NOnesIntEncoder

      public class FourFlagsIntEncoder
      extends ChunksIntEncoder

  A `ChunksIntEncoder` which encodes values in chunks of 4. Every group starts with a single byte (called indicator) which represents 4 - 2 bit flags, where the values:
  - 1, 2 or 3 mean the encoded value is '1', '2' or '3' respectively.
  - 0 means the value is encoded using `VInt8IntEncoder`, and the encoded bytes follow the indicator.
    Since value 0 is illegal, and 1-3 are encoded in the indicator, the actual value that is encoded is `value-4`, which saves some more bits.
  Encoding example:
  - Original values: 6, 16, 5, 9, 7, 1, 11
  - After sorting: 1, 5, 6, 7, 9, 11, 16
  - D-Gap computing: 1, 4, 1, 1, 2, 5 (so far - done by `DGapIntEncoder`)
  - Encoding: 1,0,1,1 as the first indicator, followed by 0 (4-4), than 2,0,0,0 as the second indicator, followed by 1 (5-4) encoded with.
  - Binary encode: 01 | 01 | 00 | 01 00000000 00 | 00 | 00 | 10 00000001 (indicators are underlined).
    NOTE: the order of the values in the indicator is lsb ⇒ msb, which allows for more efficient decoding.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.facet.encoding.ChunksIntEncoder

      `encodeQueue, indicator, ordinal`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FourFlagsIntEncoder()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `IntDecoder` | `createMatchingDecoder()` Returns an `IntDecoder` which can decode the values that were encoded with this encoder.
    `void` | `encode(IntsRef values, BytesRef buf)` Encodes the values to the given buffer.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.lucene.facet.encoding.ChunksIntEncoder

      `encodeChunk`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FourFlagsIntEncoder

          public FourFlagsIntEncoder()

  - ### Method Detail

    - #### encode

          public void encode(IntsRef values,
                    BytesRef buf)

      Description copied from class: `IntEncoder`
      Encodes the values to the given buffer. Note that the buffer's offset and length are set to 0.
      Specified by:
        `encode` in class `IntEncoder`

    - #### createMatchingDecoder

          public IntDecoder createMatchingDecoder()

      Description copied from class: `IntEncoder`
      Returns an `IntDecoder` which can decode the values that were encoded with this encoder.
      Specified by:
        `createMatchingDecoder` in class `IntEncoder`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.