org.apache.lucene.util.encoding
Class FourFlagsIntEncoder

java.lang.Object
  extended by org.apache.lucene.util.encoding.IntEncoder
      extended by org.apache.lucene.util.encoding.ChunksIntEncoder
          extended by org.apache.lucene.util.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:

Encoding example:

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

Field Summary
 
Fields inherited from class org.apache.lucene.util.encoding.ChunksIntEncoder
encodeQueue, encodeQueueSize, encoder, indicator, ordinal
 
Fields inherited from class org.apache.lucene.util.encoding.IntEncoder
out
 
Constructor Summary
FourFlagsIntEncoder()
           
 
Method Summary
 IntDecoder createMatchingDecoder()
          Returns an IntDecoder which matches this encoder.
 void encode(int data)
          Small values (<=3) are stored in the indicator while larger values are saved for later encoding in the ChunksIntEncoder.encodeQueue.
 String toString()
           
 
Methods inherited from class org.apache.lucene.util.encoding.ChunksIntEncoder
close, encodeChunk, reInit
 
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(int data)
            throws IOException
Small values (<=3) are stored in the indicator while larger values are saved for later encoding in the ChunksIntEncoder.encodeQueue. Since Vint8 will only encode values larger or equal to 4, the values saves for encoded are transformed to (value - 4).
When a chunk is ready (got 4 values), the ChunksIntEncoder.encodeChunk() takes control.

Specified by:
encode in class IntEncoder
Throws:
IOException

createMatchingDecoder

public IntDecoder createMatchingDecoder()
Description copied from class: IntEncoder
Returns an IntDecoder which matches this encoder. Every encoder must return an IntDecoder and null is not a valid value. If an encoder is just a filter, it should at least return its wrapped encoder's matching decoder.

NOTE: this method should create a new instance of the matching decoder and leave the instance sharing to the caller. Returning the same instance over and over is risky because encoders and decoders are not thread safe.

Specified by:
createMatchingDecoder in class IntEncoder

toString

public String toString()
Overrides:
toString in class Object


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