Class BitSetEncoder
public class BitSetEncoder extends OffsetEncoder
Highly efficient when the completion status is random.
Highly inefficient when the completion status is in large blocks (RunLengthEncoder is much better)
Because our system works on manipulating INCOMPLETE offsets, it doesn't matter if the offset range we're encoding is Sequential or not. Because as records are always in commit order, if we've seen a range of offsets, we know we've seen all that exist (within said range). So if offset 8 is missing from the partition, we will encode it as having been completed (when in fact it doesn't exist), because we only compare against known incompletes, and assume all others are complete.
So, when we deserialize, the INCOMPLETES collection is then restored, and that's what's used to compare to see if a record should be skipped or not. So if record 8 is recorded as completed, it will be absent from the restored INCOMPLETES list, and we are assured we will never see record 8.
- See Also:
RunLengthEncoder,OffsetBitSet
-
Field Summary
Fields Modifier and Type Field Description static IntegerMAX_LENGTH_ENCODABLE -
Constructor Summary
Constructors Constructor Description BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder)BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder, OffsetEncoding.Version newVersion) -
Method Summary
Modifier and Type Method Description voidencodeCompletedOffset(int index)voidencodeIncompleteOffset(int index)BitSetgetBitSet()protected byte[]getEncodedBytes()intgetEncodedSize()protected OffsetEncodinggetEncodingType()protected OffsetEncodinggetEncodingTypeCompressed()byte[]serialise()
-
Field Details
-
Constructor Details
-
BitSetEncoder
public BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder) throws BitSetEncodingNotSupportedException -
BitSetEncoder
public BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder, OffsetEncoding.Version newVersion) throws BitSetEncodingNotSupportedException- Parameters:
length- the difference between the highest and lowest offset to be encoded- Throws:
BitSetEncodingNotSupportedException
-
-
Method Details
-
getEncodingType
- Specified by:
getEncodingTypein classOffsetEncoder
-
getEncodingTypeCompressed
- Specified by:
getEncodingTypeCompressedin classOffsetEncoder
-
encodeIncompleteOffset
public void encodeIncompleteOffset(int index) -
encodeCompletedOffset
public void encodeCompletedOffset(int index) -
serialise
-
getEncodedSize
public int getEncodedSize() -
getEncodedBytes
protected byte[] getEncodedBytes()- Specified by:
getEncodedBytesin classOffsetEncoder
-
getBitSet
-