ifesdjeen commented on code in PR #259:
URL: https://github.com/apache/cassandra-accord/pull/259#discussion_r2550114587
##########
accord-core/src/main/java/accord/primitives/KnownMap.java:
##########
@@ -286,25 +286,45 @@ private static Known reduceKnownFor(MinAndMaxKnown
bounds, @Nullable Known prev)
public Participants<?> knownFor(Known required, Participants<?> expect)
{
- return foldlWithDefaultAndBounds(expect, (known, prev, start, end) -> {
+ return foldlWithBounds(expect, (known, prev, start, end) -> {
if (known == null || !required.isSatisfiedBy(known.max))
{
- if (end != null)
+ if (start != null && end != null)
return
prev.without(Ranges.of(start.rangeFactory().newAntiRange(start, end)));
- int i = prev.find(start, FAST);
- if (i < 0)
- return prev.slice(0, -1 - i);
+ if (start == null && end == null)
+ return prev.slice(0, 0);
- if (prev.domain() == Routable.Domain.Key)
- return prev.slice(0, i + 1);
+ if (start == null)
+ {
+ int i = prev.find(end, FAST);
+ if (i < 0)
+ return prev.slice(-1 - i, prev.size());
- Range r = prev.get(i).asRange();
- Range newR = r.start().equals(start) ? start.asRange() :
r.newRange(r.start(), start);
- return prev.slice(0, i).with((Participants)Ranges.of(newR));
+ if (prev.domain() == Routable.Domain.Key)
+ return prev.slice(i + 1, prev.size());
+
+ Range r = prev.get(i).asRange();
+ Range newR = r.end().equals(end) ? end.asRange() :
r.newRange(r.end(), end);
+ return prev.slice(i,
prev.size()).with((Participants)Ranges.of(newR));
+
+ }
+ else
+ {
+ int i = prev.find(start, FAST);
+ if (i < 0)
+ return prev.slice(0, -1 - i);
+
+ if (prev.domain() == Routable.Domain.Key)
+ return prev.slice(0, i + 1);
+
+ Range r = prev.get(i).asRange();
+ Range newR = r.start().equals(start) ? start.asRange() :
r.newRange(r.start(), start);
+ return prev.slice(0,
i).with((Participants)Ranges.of(newR));
Review Comment:
I might be misunderstanding, but shouldn't it be `I + 1` here?
##########
accord-core/src/main/java/accord/primitives/KnownMap.java:
##########
@@ -286,25 +286,45 @@ private static Known reduceKnownFor(MinAndMaxKnown
bounds, @Nullable Known prev)
public Participants<?> knownFor(Known required, Participants<?> expect)
{
- return foldlWithDefaultAndBounds(expect, (known, prev, start, end) -> {
+ return foldlWithBounds(expect, (known, prev, start, end) -> {
if (known == null || !required.isSatisfiedBy(known.max))
{
- if (end != null)
+ if (start != null && end != null)
return
prev.without(Ranges.of(start.rangeFactory().newAntiRange(start, end)));
- int i = prev.find(start, FAST);
- if (i < 0)
- return prev.slice(0, -1 - i);
+ if (start == null && end == null)
+ return prev.slice(0, 0);
- if (prev.domain() == Routable.Domain.Key)
- return prev.slice(0, i + 1);
+ if (start == null)
+ {
+ int i = prev.find(end, FAST);
+ if (i < 0)
+ return prev.slice(-1 - i, prev.size());
- Range r = prev.get(i).asRange();
- Range newR = r.start().equals(start) ? start.asRange() :
r.newRange(r.start(), start);
- return prev.slice(0, i).with((Participants)Ranges.of(newR));
+ if (prev.domain() == Routable.Domain.Key)
+ return prev.slice(i + 1, prev.size());
+
+ Range r = prev.get(i).asRange();
+ Range newR = r.end().equals(end) ? end.asRange() :
r.newRange(r.end(), end);
Review Comment:
Again I might be misunderstanding, but shouldn't it be `end, r.end()`?
##########
accord-core/src/main/java/accord/topology/TopologyMismatch.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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 accord.topology;
+
+import javax.annotation.Nullable;
+
+import accord.primitives.Ranges;
+import accord.primitives.Routables;
+import accord.utils.Invariants;
+import accord.utils.UnhandledEnum;
+
+public class TopologyMismatch extends TopologyException
+{
+ public enum TopologyMatch { LATEST, ANY }
Review Comment:
Could you add a short description? From what I understand, any is used for
sync points right?
##########
accord-core/src/main/java/accord/topology/TopologyMismatch.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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 accord.topology;
+
+import javax.annotation.Nullable;
+
+import accord.primitives.Ranges;
+import accord.primitives.Routables;
+import accord.utils.Invariants;
+import accord.utils.UnhandledEnum;
+
+public class TopologyMismatch extends TopologyException
+{
+ public enum TopologyMatch { LATEST, ANY }
+
+ private TopologyMismatch(String message)
+ {
+ super(message);
+ }
+
+ private TopologyMismatch(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ @Override
+ public TopologyMismatch rethrowable()
+ {
+ Invariants.require(this.getClass() == TopologyMismatch.class);
Review Comment:
Maybe could just make the class final above?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]