Class SortingIntEncoder
- java.lang.Object
-
- org.apache.lucene.util.encoding.IntEncoder
-
- org.apache.lucene.util.encoding.IntEncoderFilter
-
- org.apache.lucene.util.encoding.SortingIntEncoder
-
public class SortingIntEncoder extends IntEncoderFilter
AnIntEncoderFilterwhich sorts the values to encode in ascending order before encoding them. Encoding therefore happens upon callingclose(). Since this encoder is usually chained with another encoder that relies on sorted values, it does not offer a default constructor.- 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 SortingIntEncoder(IntEncoder encoder)Initializes with the given encoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Instructs the encoder to finish the encoding process.IntDecodercreateMatchingDecoder()Returns anIntDecoderwhich matches this encoder.voidencode(int value)Encodes an integer to the output stream given inreInitvoidreInit(OutputStream out)Reinitializes the encoder with the giveOutputStream.StringtoString()
-
-
-
Constructor Detail
-
SortingIntEncoder
public SortingIntEncoder(IntEncoder encoder)
Initializes with the given encoder.
-
-
Method Detail
-
close
public void close() throws IOExceptionDescription copied from class:IntEncoderInstructs the encoder to finish the encoding process. This method closes the output stream which was specified byreInit. An implementation may do here additional cleanup required to complete the encoding, such as flushing internal buffers, etc.
Once this method was called, no further calls toencodeshould be made before first callingreInit.NOTE: overriding classes should make sure they either call
super.close()or close the output stream themselves.- Overrides:
closein classIntEncoderFilter- Throws:
IOException
-
encode
public void encode(int value) throws IOExceptionDescription copied from class:IntEncoderEncodes an integer to the output stream given inreInit- Specified by:
encodein classIntEncoder- Throws:
IOException
-
createMatchingDecoder
public IntDecoder createMatchingDecoder()
Description copied from class:IntEncoderReturns anIntDecoderwhich matches this encoder. Every encoder must return anIntDecoderandnullis 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:
createMatchingDecoderin classIntEncoder
-
reInit
public void reInit(OutputStream out)
Description copied from class:IntEncoderReinitializes 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 ofIntEncodermay write some metadata about themselves to the output stream, and therefore it is imperative that one calls this method before encoding any data.- Overrides:
reInitin classIntEncoderFilter
-
-