[ 
https://issues.apache.org/jira/browse/BEAM-3485?focusedWorklogId=91741&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-91741
 ]

ASF GitHub Bot logged work on BEAM-3485:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Apr/18 13:18
            Start Date: 17/Apr/18 13:18
    Worklog Time Spent: 10m 
      Work Description: aromanenko-dev 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_r182065055
 
 

 ##########
 File path: 
sdks/java/io/cassandra/src/main/java/org/apache/beam/sdk/io/cassandra/RingRange.java
 ##########
 @@ -0,0 +1,155 @@
+/*
+ * 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 java.math.BigInteger;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Models a Cassandra token range.
+ */
+public final class RingRange {
+
+  /**
+   * Allows to order token ranges by start token.
+   */
+  public static final Comparator<RingRange> START_COMPARATOR =
+      (RingRange o1, RingRange o2) -> o1.start.compareTo(o2.start);
+
+  private final BigInteger start;
+  private final BigInteger end;
+
+  public RingRange(BigInteger start, BigInteger end) {
+    this.start = start;
+    this.end = end;
+  }
+
+  public RingRange(String... range) {
+    start = new BigInteger(range[0]);
+    end = new BigInteger(range[1]);
+  }
+
+  public BigInteger getStart() {
+    return start;
+  }
+
+  public BigInteger getEnd() {
+    return end;
+  }
+
+  /**
+   * Returns the size of this range.
+   *
+   * @return size of the range, max - range, in case of wrap
+   */
+  public BigInteger span(BigInteger ringSize) {
+    if (SplitGenerator.greaterThanOrEqual(start, end)) {
+      return end.subtract(start).add(ringSize);
+    } else {
+      return end.subtract(start);
+    }
+  }
+
+  /**
+   * @return true if other is enclosed in this range.
+   */
+  public boolean encloses(RingRange other) {
 
 Review comment:
   Is this method used somewhere?

----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 91741)
    Time Spent: 1.5h  (was: 1h 20m)

> 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: 1.5h
>  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)

Reply via email to