[
https://issues.apache.org/jira/browse/BEAM-3485?focusedWorklogId=95578&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-95578
]
ASF GitHub Bot logged work on BEAM-3485:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Apr/18 16:12
Start Date: 26/Apr/18 16:12
Worklog Time Spent: 10m
Work Description: iemejia commented on a change in pull request #5124:
[BEAM-3485] Fix split generation for Cassandra clusters
URL: https://github.com/apache/beam/pull/5124#discussion_r184447540
##########
File path:
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/SplitGenerator.java
##########
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.cassandra;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Splits given Cassandra table's token range into splits. */
+final class SplitGenerator {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(SplitGenerator.class);
+
+ private final String partitioner;
+ private final BigInteger rangeMin;
+ private final BigInteger rangeMax;
+ private final BigInteger rangeSize;
+
+ SplitGenerator(String partitioner) {
+ rangeMin = getRangeMin(partitioner);
+ rangeMax = getRangeMax(partitioner);
+ rangeSize = getRangeSize(partitioner);
+ this.partitioner = partitioner;
+ }
+
+ private static BigInteger getRangeMin(String partitioner) {
+ if (partitioner.endsWith("RandomPartitioner")) {
+ return BigInteger.ZERO;
+ } else if (partitioner.endsWith("Murmur3Partitioner")) {
+ return new BigInteger("2").pow(63).negate();
+ } else {
+ throw new UnsupportedOperationException(
+ "Unsupported partitioner. " + "Only Random and Murmur3 are
supported");
+ }
+ }
+
+ private static BigInteger getRangeMax(String partitioner) {
+ if (partitioner.endsWith("RandomPartitioner")) {
+ return new BigInteger("2").pow(127).subtract(BigInteger.ONE);
+ } else if (partitioner.endsWith("Murmur3Partitioner")) {
+ return new BigInteger("2").pow(63).subtract(BigInteger.ONE);
+ } else {
+ throw new UnsupportedOperationException(
+ "Unsupported partitioner. " + "Only Random and Murmur3 are
supported");
+ }
+ }
+
+ static BigInteger getRangeSize(String partitioner) {
+ return
getRangeMax(partitioner).subtract(getRangeMin(partitioner)).add(BigInteger.ONE);
+ }
+
+ /**
+ * Given big0 properly ordered list of tokens, compute at least {@code
totalSplitCount} splits.
+ *
+ * @param totalSplitCount requested total amount of splits. This function
may generate more
+ * splits.
+ * @param ringTokens list of all start tokens in big0 cluster. They have to
be in ring order.
+ * @return big0 list containing at least {@code totalSplitCount} splits.
+ */
+ List<List<RingRange>> generateSplits(long totalSplitCount, List<BigInteger>
ringTokens) {
Review comment:
Can you please add to this documentation a brief discussion on the splitting
strategy, something like:
```The split uses smart coalescence to group token ranges that share the
same replicas together....```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 95578)
Time Spent: 5h 20m (was: 5h 10m)
> CassandraIO.read() splitting produces invalid queries
> -----------------------------------------------------
>
> Key: BEAM-3485
> URL: https://issues.apache.org/jira/browse/BEAM-3485
> Project: Beam
> Issue Type: Bug
> Components: io-java-cassandra
> Reporter: Eugene Kirpichov
> Assignee: Alexander Dejanovski
> Priority: Major
> Time Spent: 5h 20m
> Remaining Estimate: 0h
>
> See
> [https://stackoverflow.com/questions/48090668/how-to-increase-dataflow-read-parallelism-from-cassandra/48131264?noredirect=1#comment83548442_48131264]
> As the question author points out, the error is likely that token($pk) should
> be token(pk). This was likely masked by BEAM-3424 and BEAM-3425, and the
> splitting code path effectively was never invoked, and was broken from the
> first PR - so there are likely other bugs.
> When testing this issue, we must ensure good code coverage in an IT against a
> real Cassandra instance.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)