|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.util.encoding.IntEncoder
org.apache.lucene.util.encoding.ChunksIntEncoder
org.apache.lucene.util.encoding.FourFlagsIntEncoder
org.apache.lucene.util.encoding.NOnesIntEncoder
public class NOnesIntEncoder
A variation of FourFlagsIntEncoder which translates the data as
follows:
value+1 (2 ⇒ 3, 3
⇒ 4 and so forth).
N occurrences of 1 are encoded as a single 2.
Encoding examples:
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.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.
| 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 | |
|---|---|
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 | |
|---|---|
void |
close()
Instructs the encoder to finish the encoding process. |
IntDecoder |
createMatchingDecoder()
Returns an IntDecoder which matches this encoder. |
void |
encode(int value)
Small values (<=3) are stored in the indicator while larger
values are saved for later encoding in the ChunksIntEncoder.encodeQueue. |
void |
reInit(OutputStream out)
Reinitializes the encoder with the give OutputStream. |
String |
toString()
|
| Methods inherited from class org.apache.lucene.util.encoding.ChunksIntEncoder |
|---|
encodeChunk |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NOnesIntEncoder(int n)
| Method Detail |
|---|
public void close()
throws IOException
IntEncoderreInit. An implementation may do here additional cleanup required to
complete the encoding, such as flushing internal buffers, etc.encode should be made before first calling reInit.
NOTE: overriding classes should make sure they either call
super.close() or close the output stream themselves.
close in class ChunksIntEncoderIOException
public void encode(int value)
throws IOException
FourFlagsIntEncoderindicator 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).ChunksIntEncoder.encodeChunk()
takes control.
encode in class FourFlagsIntEncoderIOExceptionpublic IntDecoder createMatchingDecoder()
IntEncoderIntDecoder 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.
createMatchingDecoder in class FourFlagsIntEncoderpublic void reInit(OutputStream out)
IntEncoderOutputStream. 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 of
IntEncoder may write some metadata about themselves to the output
stream, and therefore it is imperative that one calls this method before
encoding any data.
reInit in class ChunksIntEncoderpublic String toString()
toString in class FourFlagsIntEncoder
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||