org.apache.lucene.facet.encoding
Class NOnesIntEncoder

java.lang.Object
  extended by org.apache.lucene.facet.encoding.IntEncoder
      extended by org.apache.lucene.facet.encoding.ChunksIntEncoder
          extended by org.apache.lucene.facet.encoding.FourFlagsIntEncoder
              extended by org.apache.lucene.facet.encoding.NOnesIntEncoder

public class NOnesIntEncoder
extends FourFlagsIntEncoder

A variation of FourFlagsIntEncoder which translates the data as follows:

Encoding examples:

NOTE: this encoder does not support values ≤ 0 and Integer.MAX_VALUE. 0 is not supported because it's not supported by FourFlagsIntEncoder and Integer.MAX_VALUE because this encoder translates N to N+1, which will cause an overflow and Integer.MAX_VALUE will become a negative number, which is not supported as well.
This does not mean you cannot encode Integer.MAX_VALUE. If it is not the first value to encode, and you wrap this encoder with DGapIntEncoder, then the value that will be sent to this encoder will be MAX_VAL - prev.

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
NOnesIntEncoder(int n)
          Constructs an encoder with a given value of N (N: Number of consecutive '1's to be translated into single target value '2').
 
Method Summary
 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

NOnesIntEncoder

public NOnesIntEncoder(int n)
Constructs an encoder with a given value of N (N: Number of consecutive '1's to be translated into single target value '2').

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.

Overrides:
encode in class FourFlagsIntEncoder

createMatchingDecoder

public IntDecoder createMatchingDecoder()
Description copied from class: IntEncoder
Returns an IntDecoder which can decode the values that were encoded with this encoder.

Overrides:
createMatchingDecoder in class FourFlagsIntEncoder

toString

public String toString()
Overrides:
toString in class FourFlagsIntEncoder


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