## org.apache.lucene.facet.encoding
Class ChunksIntEncoder

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

Direct Known Subclasses:
  EightFlagsIntEncoder, FourFlagsIntEncoder

    public abstract class ChunksIntEncoder

extends IntEncoder

An `IntEncoder` which encodes values in chunks. Implementations of this class assume the data which needs encoding consists of small, consecutive values, and therefore the encoder is able to compress them better. You can read more on the two implementations `FourFlagsIntEncoder` and `EightFlagsIntEncoder`.

Extensions of this class need to implement `IntEncoder.encode(IntsRef, BytesRef)` in order to build the proper indicator (flags). When enough values were accumulated (typically the batch size), extensions can call `encodeChunk(BytesRef)` to flush the indicator and the rest of the values.

NOTE: flags encoders do not accept values ≤ 0 (zero) in their `IntEncoder.encode(IntsRef, BytesRef)`. For performance reasons they do not check that condition, however if such value is passed the result stream may be corrupt or an exception will be thrown. Also, these encoders perform the best when there are many consecutive small values (depends on the encoder implementation). If that is not the case, the encoder will occupy 1 more byte for every batch number of integers, over whatever `VInt8IntEncoder` would have occupied. Therefore make sure to check whether your data fits into the conditions of the specific encoder.

For the reasons mentioned above, these encoders are usually chained with `UniqueValuesIntEncoder` and `DGapIntEncoder`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
`protected IntsRef` `encodeQueue` Holds the values which must be encoded, outside the indicator.
`protected int` `indicator` Represents bits flag byte.
`protected byte` `ordinal` Counts the current ordinal of the encoded value.

Constructor Summary
`protected` `ChunksIntEncoder(int chunkSize)`

Method Summary
`protected void` `encodeChunk(BytesRef buf)` Encodes the values of the current chunk.

Methods inherited from class org.apache.lucene.facet.encoding.IntEncoder
`createMatchingDecoder, encode`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### encodeQueue

    protected final IntsRef encodeQueue

  Holds the values which must be encoded, outside the indicator.

### indicator

    protected int indicator

  Represents bits flag byte.

### ordinal

    protected byte ordinal

  Counts the current ordinal of the encoded value.

Constructor Detail

### ChunksIntEncoder

    protected ChunksIntEncoder(int chunkSize)

Method Detail

### encodeChunk

    protected void encodeChunk(BytesRef buf)

  Encodes the values of the current chunk. First it writes the indicator, and then it encodes the values outside the indicator.

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