cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdeggleston <...@git.apache.org>
Subject [GitHub] cassandra pull request #224: 14405 replicas
Date Fri, 18 May 2018 21:27:33 GMT
Github user bdeggleston commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/224#discussion_r189397458
  
    --- Diff: src/java/org/apache/cassandra/locator/PendingRangeMaps.java ---
    @@ -23,196 +23,176 @@
     import com.google.common.collect.Iterators;
     import org.apache.cassandra.dht.Range;
     import org.apache.cassandra.dht.Token;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
     
     import java.util.*;
     
    -public class PendingRangeMaps implements Iterable<Map.Entry<Range<Token>,
List<InetAddressAndPort>>>
    +public class PendingRangeMaps implements Iterable<Map.Entry<Range<Token>,
List<Replica>>>
     {
    -    private static final Logger logger = LoggerFactory.getLogger(PendingRangeMaps.class);
    -
         /**
          * We have for NavigableMap to be able to search for ranges containing a token efficiently.
          *
          * First two are for non-wrap-around ranges, and the last two are for wrap-around
ranges.
          */
         // ascendingMap will sort the ranges by the ascending order of right token
    -    final NavigableMap<Range<Token>, List<InetAddressAndPort>> ascendingMap;
    +    private final NavigableMap<Range<Token>, List<Replica>> ascendingMap;
    +
         /**
          * sorting end ascending, if ends are same, sorting begin descending, so that token
(end, end) will
          * come before (begin, end] with the same end, and (begin, end) will be selected
in the tailMap.
          */
    -    static final Comparator<Range<Token>> ascendingComparator = new Comparator<Range<Token>>()
    -        {
    -            @Override
    -            public int compare(Range<Token> o1, Range<Token> o2)
    -            {
    -                int res = o1.right.compareTo(o2.right);
    -                if (res != 0)
    -                    return res;
    +    private static final Comparator<Range<Token>> ascendingComparator = (o1,
o2) -> {
    +        int res = o1.right.compareTo(o2.right);
    +        if (res != 0)
    +            return res;
     
    -                return o2.left.compareTo(o1.left);
    -            }
    -        };
    +        return o2.left.compareTo(o1.left);
    +    };
     
         // ascendingMap will sort the ranges by the descending order of left token
    -    final NavigableMap<Range<Token>, List<InetAddressAndPort>> descendingMap;
    +    private final NavigableMap<Range<Token>, List<Replica>> descendingMap;
    +
         /**
          * sorting begin descending, if begins are same, sorting end descending, so that
token (begin, begin) will
          * come after (begin, end] with the same begin, and (begin, end) won't be selected
in the tailMap.
          */
    -    static final Comparator<Range<Token>> descendingComparator = new Comparator<Range<Token>>()
    -        {
    -            @Override
    -            public int compare(Range<Token> o1, Range<Token> o2)
    -            {
    -                int res = o2.left.compareTo(o1.left);
    -                if (res != 0)
    -                    return res;
    +    private static final Comparator<Range<Token>> descendingComparator =
(o1, o2) -> {
    +        int res = o2.left.compareTo(o1.left);
    +        if (res != 0)
    +            return res;
     
    -                // if left tokens are same, sort by the descending of the right tokens.
    -                return o2.right.compareTo(o1.right);
    -            }
    -        };
    +        // if left tokens are same, sort by the descending of the right tokens.
    +        return o2.right.compareTo(o1.right);
    +    };
     
         // these two maps are for warp around ranges.
    -    final NavigableMap<Range<Token>, List<InetAddressAndPort>> ascendingMapForWrapAround;
    +    private final NavigableMap<Range<Token>, List<Replica>> ascendingMapForWrapAround;
    +
         /**
          * for wrap around range (begin, end], which begin > end.
          * Sorting end ascending, if ends are same, sorting begin ascending,
          * so that token (end, end) will come before (begin, end] with the same end, and
(begin, end] will be selected in
          * the tailMap.
          */
    -    static final Comparator<Range<Token>> ascendingComparatorForWrapAround
= new Comparator<Range<Token>>()
    -    {
    -        @Override
    -        public int compare(Range<Token> o1, Range<Token> o2)
    -        {
    -            int res = o1.right.compareTo(o2.right);
    -            if (res != 0)
    -                return res;
    +    private static final Comparator<Range<Token>> ascendingComparatorForWrapAround
= (o1, o2) -> {
    +        int res = o1.right.compareTo(o2.right);
    +        if (res != 0)
    +            return res;
     
    -            return o1.left.compareTo(o2.left);
    -        }
    +        return o1.left.compareTo(o2.left);
         };
     
    -    final NavigableMap<Range<Token>, List<InetAddressAndPort>> descendingMapForWrapAround;
    +    private final NavigableMap<Range<Token>, List<Replica>> descendingMapForWrapAround;
    +
         /**
          * for wrap around ranges, which begin > end.
          * Sorting end ascending, so that token (begin, begin) will come after (begin, end]
with the same begin,
          * and (begin, end) won't be selected in the tailMap.
          */
    -    static final Comparator<Range<Token>> descendingComparatorForWrapAround
= new Comparator<Range<Token>>()
    -    {
    -        @Override
    -        public int compare(Range<Token> o1, Range<Token> o2)
    -        {
    -            int res = o2.left.compareTo(o1.left);
    -            if (res != 0)
    -                return res;
    -            return o1.right.compareTo(o2.right);
    -        }
    +    private static final Comparator<Range<Token>> descendingComparatorForWrapAround
= (o1, o2) -> {
    --- End diff --
    
    :+1:


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message