Package org.apache.lucene.util.encoding
Class UniqueValuesIntEncoder
- java.lang.Object
-
- org.apache.lucene.util.encoding.IntEncoder
-
- org.apache.lucene.util.encoding.IntEncoderFilter
-
- org.apache.lucene.util.encoding.UniqueValuesIntEncoder
-
public final class UniqueValuesIntEncoder extends IntEncoderFilter
AnIntEncoderFilter
which ensures only unique values are encoded. The implementation assumes the values given toencode(int)
are sorted. If this is not the case, you can chain this encoder withSortingIntEncoder
.- 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.IntEncoderFilter
encoder
-
Fields inherited from class org.apache.lucene.util.encoding.IntEncoder
out
-
-
Constructor Summary
Constructors Constructor Description UniqueValuesIntEncoder(IntEncoder encoder)
Constructs a new instance with the given encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntDecoder
createMatchingDecoder()
Returns anIntDecoder
which matches this encoder.void
encode(int value)
Encodes an integer to the output stream given inreInit
void
reInit(OutputStream out)
Reinitializes the encoder with the giveOutputStream
.String
toString()
-
Methods inherited from class org.apache.lucene.util.encoding.IntEncoderFilter
close
-
-
-
-
Constructor Detail
-
UniqueValuesIntEncoder
public UniqueValuesIntEncoder(IntEncoder encoder)
Constructs a new instance with the given encoder.
-
-
Method Detail
-
encode
public void encode(int value) throws IOException
Description copied from class:IntEncoder
Encodes an integer to the output stream given inreInit
- Specified by:
encode
in classIntEncoder
- Throws:
IOException
-
createMatchingDecoder
public IntDecoder createMatchingDecoder()
Description copied from class:IntEncoder
Returns anIntDecoder
which matches this encoder. Every encoder must return anIntDecoder
andnull
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 classIntEncoder
-
reInit
public void reInit(OutputStream out)
Description copied from class:IntEncoder
Reinitializes the encoder with the giveOutputStream
. For re-usability it can be changed without the need to reconstruct a new object.NOTE: after calling
IntEncoder.close()
, one must call this method even if the output stream itself hasn't changed. An example case is that the output stream wraps a byte[], and the output stream itself is reset, but its instance hasn't changed. Some implementations ofIntEncoder
may write some metadata about themselves to the output stream, and therefore it is imperative that one calls this method before encoding any data.- Overrides:
reInit
in classIntEncoderFilter
-
-