Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improvements to encoding ranges (int vs long) #439

Merged
merged 141 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 136 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
9abeacb
build(deps): bump testcontainers.version from 1.17.1 to 1.17.2
dependabot[bot] May 20, 2022
29ca397
build(deps): bump versions-maven-plugin from 2.10.0 to 2.11.0
dependabot[bot] May 20, 2022
ec21ad0
START: Try to reproduce issue #184 - run against multiple topics
astubbs May 21, 2022
1b9d2ad
test compiles
astubbs May 21, 2022
51ef075
failling test
astubbs May 22, 2022
7e32d4d
fixes test - introduce ShardKey
astubbs May 22, 2022
0a558f6
step
astubbs May 23, 2022
9628bee
step
astubbs May 24, 2022
b1fd89e
step
astubbs May 24, 2022
d237158
turn off ossindex for guava 31.1
astubbs May 24, 2022
d8ea983
step
astubbs May 24, 2022
b883ba0
step - extract
astubbs May 24, 2022
4219a99
build(deps): bump vertx.version from 4.3.0 to 4.3.1
dependabot[bot] May 25, 2022
ae21fb7
step - tg demo, keep consumer open
astubbs May 26, 2022
ad6c89e
test for null keys
astubbs Jun 1, 2022
23e5389
allow truth snapshot
astubbs Jun 1, 2022
7fdb06a
add missing annotations
astubbs Jun 10, 2022
3e611d8
build(deps-dev): bump postgresql from 42.3.5 to 42.4.0
dependabot[bot] Jun 10, 2022
03ff349
step
astubbs Jun 25, 2022
72ac264
build: Exclude Guava 31.1 from OSSIndex sec scan
astubbs Jun 1, 2022
f905cdb
...
astubbs Jul 9, 2022
12dc7cf
build: Update to Truth-Generator 0.1.1 for Subject discovery
astubbs Jul 9, 2022
bf37740
Merge branch 'exclude-guava-oss-index' into bugs/issue-184-reproduce
astubbs Jul 9, 2022
080ecd3
Merge remote-tracking branch 'confluent/dependabot/maven/testcontaine…
astubbs Jul 9, 2022
71a48dc
Merge remote-tracking branch 'confluent/dependabot/maven/org.postgres…
astubbs Jul 9, 2022
a087efb
Merge remote-tracking branch 'confluent/dependabot/maven/org.codehaus…
astubbs Jul 9, 2022
3e468a7
build: Only run OSS Index audit on runtime dependencies, not tests
astubbs Jul 9, 2022
10ac83a
build: Only run OSS Index audit on runtime dependencies, not tests
astubbs Jul 9, 2022
7efc8de
build: Don't fail for OSSIndex scan - will set up another CI job for …
astubbs Jul 9, 2022
70a37cd
build: Don't fail for OSSIndex scan - will set up another CI job for …
astubbs Jul 9, 2022
ad44c8d
Merge branch 'exclude-guava-oss-index' into improvements/version-bumps
astubbs Jul 9, 2022
f2ec1dd
fix cherry-pick
astubbs Jul 9, 2022
fba5ca5
Merge branch 'exclude-guava-oss-index' into improvements/version-bumps
astubbs Jul 9, 2022
d17f617
Merge branch 'improvements/version-bumps' into bugs/issue-184-reproduce
astubbs Jul 9, 2022
223e087
Revert "allow truth snapshot"
astubbs Jul 9, 2022
0d2b370
build: Only enforce requireReleaseDeps when running in CI, not locally
astubbs Jul 9, 2022
3ff1724
Merge branch 'exclude-guava-oss-index' into bugs/issue-184-reproduce
astubbs Jul 9, 2022
9f18470
stale test?
astubbs Jul 9, 2022
f3e73ea
ConsumerSubject blocked by PC no multi threaded access
astubbs Jul 9, 2022
00c581a
TEMPORARY: use TG 0.1.1 snapshot
astubbs Jun 30, 2022
d396e66
Merge branch 'exclude-guava-oss-index' into improvements/upgrade-tg
astubbs Jul 11, 2022
4f2de5c
remove guava exclude from branch
astubbs Jul 11, 2022
ad5092c
cleanse branch
astubbs Jul 11, 2022
30ea0c9
Merge branch 'improvements/allow-snapshots-locally' into improvements…
astubbs Jul 11, 2022
d7267d7
Merge remote-tracking branch 'antony/improvements/upgrade-tg' into im…
astubbs Jul 11, 2022
5e0db16
test snapshot first
astubbs Jul 11, 2022
ac65300
test snapshot first
astubbs Jul 11, 2022
dce76c2
Merge remote-tracking branch 'origin/master' into improvements/upgrad…
astubbs Jul 11, 2022
647675d
Merge remote-tracking branch 'origin/master' into bugs/issue-184-repr…
astubbs Jul 11, 2022
ab5a528
test mutli topic with simply creating a new consumer and checking ass…
astubbs Jul 11, 2022
186144d
update after rename
astubbs Jul 11, 2022
828c1b2
Merge branch 'improvements/upgrade-tg' into bugs/issue-184-reproduce
astubbs Jul 11, 2022
38bf42e
fixup! test mutli topic with simply creating a new consumer and check…
astubbs Jul 11, 2022
bb61774
fixup! test mutli topic with simply creating a new consumer and check…
astubbs Jul 11, 2022
914dc59
switch from NewTopic to TopicPartitions
astubbs Jul 11, 2022
75287fa
ide: Add All test run target
astubbs Jul 11, 2022
906d3fe
Merge remote-tracking branch 'confluent/master' into bugs/issue-184-r…
astubbs Jul 11, 2022
a999242
review
astubbs Jul 11, 2022
f88494a
review
astubbs Jul 11, 2022
9010da5
review
astubbs Jul 12, 2022
fa24a2f
START: Missing javadoc
astubbs Jul 12, 2022
c6f264e
step
astubbs Jul 12, 2022
a5b1573
review
astubbs Jul 12, 2022
5e8bfb6
START: fixes #409: Truncate state on offset high reset
astubbs Sep 30, 2022
d1c42d6
review
astubbs Sep 30, 2022
5dca73c
review
astubbs Sep 30, 2022
23c289f
step - continuous checking and restructure
astubbs Sep 30, 2022
70c06a5
Merge remote-tracking branch 'origin/master' into improvements/javadoc
astubbs Sep 30, 2022
1fcc658
review
astubbs Sep 30, 2022
2ea3573
incomplete offsets docs
astubbs Oct 1, 2022
835888a
docs and rename
astubbs Oct 1, 2022
f58c467
fixup! review
astubbs Oct 1, 2022
000969c
Revert "step - continuous checking and restructure"
astubbs Oct 1, 2022
b4af22a
clean up tangents, clarify
astubbs Oct 1, 2022
26ee4b8
pruneRemovedTrackedIncompleteOffsets and detect committed offset rese…
astubbs Oct 4, 2022
87dd82e
test scenarios
astubbs Oct 5, 2022
5c41b3f
tests
astubbs Oct 5, 2022
0a13ca6
issue #409 captured in test and fixed
astubbs Oct 6, 2022
d713b29
three scenarios captured and fixed
astubbs Oct 6, 2022
3336746
SAVE: fixing tests
astubbs Oct 6, 2022
3014d8e
START: Refactor PSM and PS
astubbs Oct 1, 2022
5eca507
step: compiles
astubbs Oct 6, 2022
d97f879
delete refactored code
astubbs Oct 6, 2022
39cc5ec
START: Unify PartitionState collections
astubbs Oct 6, 2022
214605e
compiles
astubbs Oct 6, 2022
381d699
delete
astubbs Oct 6, 2022
d8f8a92
START:EXP: try changing set to list
astubbs Oct 6, 2022
7ada991
step: push TreeSet construction up to source for not change in effici…
astubbs Oct 7, 2022
66fe6f5
review
astubbs Oct 11, 2022
e977ebe
Merge remote-tracking branch 'origin/master' into fixes/state-truncat…
astubbs Oct 11, 2022
05e5ddb
changelog
astubbs Oct 11, 2022
747b132
review
astubbs Oct 11, 2022
ea9b51a
START: Improve offset encoding data structures
astubbs Oct 11, 2022
a8e28c3
fix OffsetEncodingTests
astubbs Oct 11, 2022
6b93b1f
Draft PartitionStateCommittedOffsetIT, partially passing
astubbs Oct 11, 2022
e630134
compaction test works
astubbs Oct 11, 2022
1b73d18
run compaction on seperate broker
astubbs Oct 11, 2022
bd52b2c
compaction test review, fix higher / lower tests
astubbs Oct 11, 2022
97f3c43
offset removed test works for RESET == EARLIEST
astubbs Oct 11, 2022
9bcb14e
PartitionStateCommittedOffsetIT all green
astubbs Oct 12, 2022
fd36d14
Merge branch 'fixes/state-truncation-reset-latest' into fixes/state-t…
astubbs Oct 12, 2022
3cb5117
step: attempt merge fix
astubbs Oct 12, 2022
a1cffd0
temp make method public for TG
astubbs Oct 12, 2022
f5b5ce2
fix scm tag to HEAD
astubbs Oct 12, 2022
80ab192
validate first
astubbs Oct 12, 2022
17d13eb
review
astubbs Oct 12, 2022
7be3ab0
Merge branch 'master' into fixes/state-truncation-reset-latest
astubbs Oct 12, 2022
36f2bcb
Merge remote-tracking branch 'astubbs/fixes/state-truncation-reset-la…
astubbs Oct 12, 2022
79ba6ac
Merge branch 'refactors/refactor-psm-and-ps' into improvements/javadoc
astubbs Oct 12, 2022
bd0224c
fix NPE for RemovedPartitionState setting of a null module
astubbs Oct 12, 2022
4e0460e
Revert "fix NPE for RemovedPartitionState setting of a null module"
astubbs Oct 12, 2022
4803db9
fix NPE for RemovedPartitionState setting of a null module
astubbs Oct 12, 2022
d7c2ccf
Merge remote-tracking branch 'origin/master' into refactors/refactor-…
astubbs Oct 12, 2022
95bacaa
Implement getEpoch() and some fixes
astubbs Oct 12, 2022
e2d512b
review
astubbs Oct 12, 2022
8d7bba6
Merge branch 'refactors/refactor-psm-and-ps' into improvements/javadoc
astubbs Oct 12, 2022
3325c34
Merge branch 'improvements/javadoc' into fixes/int-to-long
astubbs Oct 12, 2022
1406b9e
compiles
astubbs Oct 12, 2022
6c473fc
Merge remote-tracking branch 'origin/master' into fixes/int-to-long
astubbs Oct 20, 2022
02edc44
Merge remote-tracking branch 'origin/master' into fixes/int-to-long
astubbs Oct 21, 2022
d276f86
fix bitset setup
astubbs Oct 21, 2022
5546e2d
review, cohesion, concerns, clarity,
astubbs Oct 21, 2022
8f0bdbb
build(deps-dev): Fix Slf4j setup by switching away from and bumping W…
astubbs Oct 21, 2022
b5ef682
Merge remote-tracking branch 'astubbs/fixes/logging' into fixes/int-t…
astubbs Oct 21, 2022
e65b7b8
remove unused constructor
astubbs Oct 21, 2022
7eaee4f
use exact casting for sanity
astubbs Oct 21, 2022
3272332
Change encoding interface to long as well
astubbs Oct 21, 2022
e2a3d05
review
astubbs Oct 21, 2022
af8f119
review
astubbs Oct 21, 2022
8dc65db
review
astubbs Oct 21, 2022
ab1ba7d
Merge branch 'master' into fixes/int-to-long
astubbs Oct 21, 2022
49ab1ef
review
astubbs Oct 21, 2022
bc6d592
review
astubbs Oct 21, 2022
920ec04
Apply suggestions from code review
astubbs Oct 26, 2022
9558e71
step: compiles, encode steps potentially throw encode exception
astubbs Oct 26, 2022
d7bfc79
test update
astubbs Oct 26, 2022
0782ae9
review, pull version up
astubbs Oct 26, 2022
e8e0d40
review
astubbs Oct 26, 2022
4aa295b
Merge remote-tracking branch 'origin/master' into fixes/int-to-long
astubbs Nov 1, 2022
6a8cbf4
minor: remove comment - uses SortedSet not Set
astubbs Nov 1, 2022
c89d9e7
Changelog entry
astubbs Nov 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.confluent.csid.utils;

/*-
* Copyright (C) 2020-2022 Confluent, Inc.
*/

import lombok.experimental.UtilityClass;

/**
* @author Antony Stubbs
*/
@UtilityClass
public class MathUtils {

/**
* Ensures exact conversion from a Long to a Short.
* <p>
* {@link Math} doesn't have an exact conversion from Long to Short.
*
* @see Math#toIntExact
*/
public static short toShortExact(long value) {
final short shortCast = (short) value;
if (shortCast != value) {
throw new ArithmeticException("short overflow");
}
return shortCast;
}
}
Original file line number Diff line number Diff line change
@@ -1,48 +1,87 @@
package io.confluent.csid.utils;

/*-
* Copyright (C) 2020-2021 Confluent, Inc.
* Copyright (C) 2020-2022 Confluent, Inc.
*/

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

import static java.util.stream.Collectors.toList;

/**
* https://stackoverflow.com/a/16570509/105741
* Class for simple ranges.
* <p>
* <a href="https://stackoverflow.com/a/16570509/105741">For loop - like Python range function</a>
*
* @see #range(long)
*/
public class Range implements Iterable<Integer> {
public class Range implements Iterable<Long> {

private final long start;

private final long limit;

/**
* @see this#range(long)
*/
public Range(int start, long max) {
this.start = start;
this.limit = max;
}

public Range(long limit) {
this.start = 0L;
this.limit = limit;
}

/**
* Exclusive of max
* Provides an {@link Iterable} for the range of numbers from 0 to the given limit.
* <p>
* Exclusive of max.
* <p>
* Consider using {@link IntStream#range(int, int)#forEachOrdered} instead:
* <pre>
* IntStream.range(0, originalBitsetSize).forEachOrdered(offset -> {
* </pre>
* However, if you don't want o use a closure, this is a good alternative.
*/
public static Range range(long max) {
return new Range(max);
}

/**
* @see #range(long)
*/
public static Range range(int start, long max) {
return new Range(start, max);
}

/**
* Potentially slow, but useful for tests
*/
public static List<Integer> listOfIntegers(int max) {
return Range.range(max).listAsIntegers();
}


@Override
public Iterator<Integer> iterator() {
public Iterator<Long> iterator() {
final long max = limit;
return new Iterator<Integer>() {
return new Iterator<>() {

private int current = 0;
private long current = start;

@Override
public boolean hasNext() {
return current < max;
}

@Override
public Integer next() {
public Long next() {
if (hasNext()) {
return current++;
} else {
Expand All @@ -57,23 +96,14 @@ public void remove() {
};
}

public List<Integer> list() {
ArrayList<Integer> integers = new ArrayList<Integer>();
forEach(integers::add);
return integers;
}

public IntStream toStream() {
return IntStream.range(0, (int) limit);
}

static IntStream rangeStream(int i) {
return IntStream.range(0, i);
public List<Integer> listAsIntegers() {
return IntStream.range(Math.toIntExact(start), Math.toIntExact(limit))
.boxed()
.collect(toList());
}

static void range(int max, Consumer<Integer> consumer) {
IntStream.range(0, max)
.forEach(consumer::accept);
public LongStream toStream() {
return LongStream.range(start, limit);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2020-2022 Confluent, Inc.
*/

import io.confluent.csid.utils.MathUtils;
import io.confluent.csid.utils.StringUtils;
import io.confluent.parallelconsumer.internal.InternalRuntimeException;
import io.confluent.parallelconsumer.state.PartitionState;
Expand Down Expand Up @@ -46,33 +47,37 @@ public class BitSetEncoder extends OffsetEncoder {

private static final Version DEFAULT_VERSION = Version.v2;

/**
* {@link BitSet} only supports {@link Integer#MAX_VALUE) bits
*/
public static final Integer MAX_LENGTH_ENCODABLE = Integer.MAX_VALUE;

@Getter
private final BitSet bitSet;

private final int originalLength;
private final long originalLength;

private Optional<byte[]> encodedBytes = Optional.empty();

astubbs marked this conversation as resolved.
Show resolved Hide resolved
public BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder) throws BitSetEncodingNotSupportedException {
this(length, offsetSimultaneousEncoder, DEFAULT_VERSION);
}

/**
* @param length the difference between the highest and lowest offset to be encoded
*/
public BitSetEncoder(int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder, Version newVersion) throws BitSetEncodingNotSupportedException {
public BitSetEncoder(long length, OffsetSimultaneousEncoder offsetSimultaneousEncoder, Version newVersion) throws BitSetEncodingNotSupportedException {
super(offsetSimultaneousEncoder);

this.version = newVersion;

bitSet = new BitSet(length);
// prep bit set buffer, range check above
try {
bitSet = new BitSet(Math.toIntExact(length));
} catch (ArithmeticException e) {
throw new BitSetEncodingNotSupportedException("BitSet only supports " + MAX_LENGTH_ENCODABLE + " bits, but " + length + " were requested", e);
}

this.originalLength = length;
}

private ByteBuffer constructWrappedByteBuffer(final int length, final Version newVersion) throws BitSetEncodingNotSupportedException {
private ByteBuffer constructWrappedByteBuffer(long length, Version newVersion) throws BitSetEncodingNotSupportedException {
return switch (newVersion) {
case v1 -> initV1(length);
case v2 -> initV2(length);
Expand All @@ -85,43 +90,39 @@ private ByteBuffer constructWrappedByteBuffer(final int length, final Version ne
* Integer.MAX_VALUE should always be good enough as system restricts large from being processed at once.
*/
// TODO refactor inivtV2 and V1 together, passing in the Short or Integer
private ByteBuffer initV2(int bitsetEntriesRequired) throws BitSetEncodingNotSupportedException {
private ByteBuffer initV2(long bitsetEntriesRequired) throws BitSetEncodingNotSupportedException {
if (bitsetEntriesRequired > MAX_LENGTH_ENCODABLE) {
// need to upgrade to using Integer for the bitset length, but can't change serialisation format in-place
throw new BitSetEncodingNotSupportedException(StringUtils.msg("BitSet V2 too long to encode, as length overflows Integer.MAX_VALUE. Length: {}. (max: {})", bitsetEntriesRequired, MAX_LENGTH_ENCODABLE));
}

// prep bit set buffer
int bytesRequiredForEntries = (int) (Math.ceil((double) bitsetEntriesRequired / Byte.SIZE));
int lengthEntryWidth = Integer.BYTES;
int wrappedBufferLength = lengthEntryWidth + bytesRequiredForEntries + 1;
final ByteBuffer wrappedBitSetBytesBuffer = ByteBuffer.allocate(wrappedBufferLength);

// bitset doesn't serialise it's set capacity, so we have to as the unused capacity actually means something
wrappedBitSetBytesBuffer.putInt(bitsetEntriesRequired);
wrappedBitSetBytesBuffer.putInt(Math.toIntExact(bitsetEntriesRequired));

return wrappedBitSetBytesBuffer;
}

/**
* This was a bit "short" sighted of me....
*
* @return
*/
private ByteBuffer initV1(int bitsetEntriesRequired) throws BitSetEncodingNotSupportedException {
private ByteBuffer initV1(long bitsetEntriesRequired) throws BitSetEncodingNotSupportedException {
if (bitsetEntriesRequired > Short.MAX_VALUE) {
// need to upgrade to using Integer for the bitset length, but can't change serialisation format in-place
throw new BitSetEncodingNotSupportedException("Input too long to encode for BitSet V1, length overflows Short.MAX_VALUE: " + bitsetEntriesRequired + ". (max: " + Short.MAX_VALUE + ")");
}

// prep bit set buffer
int bytesRequiredForEntries = (int) (Math.ceil((double) bitsetEntriesRequired / Byte.SIZE));
int lengthEntryWidth = Short.BYTES;
int wrappedBufferLength = lengthEntryWidth + bytesRequiredForEntries + 1;
final ByteBuffer wrappedBitSetBytesBuffer = ByteBuffer.allocate(wrappedBufferLength);

// bitset doesn't serialise it's set capacity, so we have to as the unused capacity actually means something
wrappedBitSetBytesBuffer.putShort((short) bitsetEntriesRequired);
wrappedBitSetBytesBuffer.putShort(MathUtils.toShortExact(bitsetEntriesRequired));

return wrappedBitSetBytesBuffer;
}
Expand All @@ -143,13 +144,14 @@ protected OffsetEncoding getEncodingTypeCompressed() {
}

@Override
public void encodeIncompleteOffset(final int index) {
public void encodeIncompleteOffset(final long relativeOffset) {
// noop - bitset defaults to 0's (`unset`)
}

@Override
public void encodeCompletedOffset(final int index) {
bitSet.set(index);
public void encodeCompletedOffset(final long relativeOffset) {
// range will already have been checked at initialization
bitSet.set(Math.toIntExact(relativeOffset));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public class ByteBufferEncoder extends OffsetEncoder {

private final ByteBuffer bytesBuffer;

public ByteBufferEncoder(final int length, OffsetSimultaneousEncoder offsetSimultaneousEncoder) {
public ByteBufferEncoder(long length, OffsetSimultaneousEncoder offsetSimultaneousEncoder) {
super(offsetSimultaneousEncoder);
this.bytesBuffer = ByteBuffer.allocate(1 + length);
// safe cast the length to an int, as we're not expecting to have more than 2^31 offsets
final int safeCast = Math.toIntExact(length);
this.bytesBuffer = ByteBuffer.allocate(1 + safeCast);
}

@Override
Expand All @@ -35,12 +37,12 @@ protected OffsetEncoding getEncodingTypeCompressed() {
}

@Override
public void encodeIncompleteOffset(final int rangeIndex) {
public void encodeIncompleteOffset(final long relativeOffset) {
this.bytesBuffer.put((byte) 0);
}

@Override
public void encodeCompletedOffset(final int rangeIndex) {
public void encodeCompletedOffset(final long relativeOffset) {
this.bytesBuffer.put((byte) 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import static io.confluent.csid.utils.Range.range;

/**
* Deserialisation tools for {@link BitSetEncoder}.
* Deserialization tools for {@link BitSetEncoder}.
* <p>
* todo unify or refactor with {@link BitSetEncoder}. Why was it ever seperate?
* todo unify or refactor with {@link BitSetEncoder}. Why was it ever separate?
*
* @author Antony Stubbs
* @see BitSetEncoder
Expand All @@ -41,8 +41,9 @@ static String deserialiseBitSet(int originalBitsetSize, ByteBuffer s) {
BitSet bitSet = BitSet.valueOf(s);

StringBuilder result = new StringBuilder(bitSet.size());
for (var offset : range(originalBitsetSize)) {
if (bitSet.get(offset)) {
for (Long offset : range(originalBitsetSize)) {
// range will already have been checked at initialization
if (bitSet.get(Math.toIntExact(offset))) {
result.append('x');
} else {
result.append('o');
Expand All @@ -69,7 +70,9 @@ static Set<Long> deserialiseBitSetToIncompletes(long baseOffset, int originalBit
BitSet bitSet = BitSet.valueOf(inputBuffer);
int numberOfIncompletes = originalBitsetSize - bitSet.cardinality();
var incompletes = new HashSet<Long>(numberOfIncompletes);
for (var relativeOffset : range(originalBitsetSize)) {
for (long relativeOffsetLong : range(originalBitsetSize)) {
// range will already have been checked at initialization
var relativeOffset = Math.toIntExact(relativeOffsetLong);
long offset = baseOffset + relativeOffset;
if (bitSet.get(relativeOffset)) {
log.trace("Ignoring completed offset {}", relativeOffset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ protected OffsetEncoder(OffsetSimultaneousEncoder offsetSimultaneousEncoder) {

protected abstract OffsetEncoding getEncodingTypeCompressed();

abstract void encodeIncompleteOffset(final int rangeIndex);
abstract void encodeIncompleteOffset(final long relativeOffset) throws EncodingNotSupportedException;

abstract void encodeCompletedOffset(final int rangeIndex);
abstract void encodeCompletedOffset(final long relativeOffset) throws EncodingNotSupportedException;

abstract byte[] serialise() throws EncodingNotSupportedException;

abstract int getEncodedSize();

boolean quiteSmall() {
return this.getEncodedSize() < OffsetSimultaneousEncoder.LARGE_INPUT_MAP_SIZE_THRESHOLD;
return this.getEncodedSize() < OffsetSimultaneousEncoder.LARGE_ENCODED_SIZE_THRESHOLD_BYTES;
}

byte[] compress() throws IOException {
Expand Down
Loading