Skip to content

[hotfix] split number is not calculated correctly in CassandraSourse #23

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/content.zh/docs/connectors/datastream/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ClusterBuilder clusterBuilder = new ClusterBuilder() {
.build();
}
};
long maxSplitMemorySize = ... //optional max split size in bytes minimum is 10MB. If not set, maxSplitMemorySize = 64 MB
long maxSplitMemorySize = ... //optional max split size in bytes minimum is 1MB. If not set, maxSplitMemorySize = 64 MB
Source cassandraSource = new CassandraSource(clusterBuilder,
maxSplitMemorySize,
Pojo.class,
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/connectors/datastream/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ClusterBuilder clusterBuilder = new ClusterBuilder() {
.build();
}
};
long maxSplitMemorySize = ... //optional max split size in bytes minimum is 10MB. If not set, maxSplitMemorySize = 64 MB
long maxSplitMemorySize = ... //optional max split size in bytes minimum is 1MB. If not set, maxSplitMemorySize = 64 MB
Source cassandraSource = new CassandraSource(clusterBuilder,
maxSplitMemorySize,
Pojo.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* .build();
* }
* };
* long maxSplitMemorySize = ... //optional max split size in bytes minimum is 10MB. If not set, maxSplitMemorySize = 64 MB
* long maxSplitMemorySize = ... //optional max split size in bytes minimum is 1MB. If not set, maxSplitMemorySize = 64 MB
* Source cassandraSource = new CassandraSource(clusterBuilder,
* maxSplitMemorySize,
* Pojo.class,
Expand Down Expand Up @@ -104,7 +104,7 @@ public class CassandraSource<OUT>
private final MapperOptions mapperOptions;

private final long maxSplitMemorySize;
private static final long MIN_SPLIT_MEMORY_SIZE = MemorySize.ofMebiBytes(10).getBytes();
private static final long MIN_SPLIT_MEMORY_SIZE = MemorySize.ofMebiBytes(1).getBytes();
static final long MAX_SPLIT_MEMORY_SIZE_DEFAULT = MemorySize.ofMebiBytes(64).getBytes();

public CassandraSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -147,7 +149,9 @@ private float getRingFraction(List<TokenRange> tokenRanges) {
addressedTokens.add(distance(tokenRange.rangeStart, tokenRange.rangeEnd));
}
// it is < 1 because it is a percentage
return addressedTokens.divide(partitioner.ringSize).floatValue();
return new BigDecimal(addressedTokens)
.divide(new BigDecimal(partitioner.ringSize), 6, RoundingMode.HALF_UP)
.floatValue();
}

/** Gets the list of token ranges that the table occupies on a given Cassandra node. */
Expand Down