Class SegmentCollection

    • Field Detail

      • segments

        protected final java.util.NavigableMap<java.lang.Double,​SegmentWithRange> segments
        Maps the upper end of a range to the corresponding segment. The range in the value is the range of keyspace the segment has been assigned. The range in the value is NOT the same as the difference between two keys. The keys correspond to the range that the client should route to, where as the one in the value is the range the segment it assigned. These may be different if a client still has a preceding segment in its map. In which case a segment's keys may not contain the full assigned range.
    • Constructor Detail

      • SegmentCollection

        public SegmentCollection​(java.util.NavigableMap<java.lang.Double,​SegmentWithRange> segments)
        Creates a new instance of the SegmentCollection class.
        Parameters:
        segments - Segments keyed by the largest key in their key range. i.e. If there are two segments split evenly, the first should have a value of 0.5 and the second 1.0.
    • Method Detail

      • hashToRange

        protected abstract double hashToRange​(java.lang.String key)
      • getSegmentForKey

        public Segment getSegmentForKey​(java.lang.String key)
      • getSegmentForKey

        public Segment getSegmentForKey​(double key)
      • getSegments

        public java.util.Collection<Segment> getSegments()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • canEqual

        protected boolean canEqual​(java.lang.Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object