Package io.pravega.client.control.impl
Class SegmentCollection
- java.lang.Object
-
- io.pravega.client.control.impl.SegmentCollection
-
- Direct Known Subclasses:
KeyValueTableSegments,StreamSegments
public abstract class SegmentCollection extends java.lang.ObjectOrganizes Segments by key ranges.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.NavigableMap<java.lang.Double,SegmentWithRange>segmentsMaps the upper end of a range to the corresponding segment.
-
Constructor Summary
Constructors Constructor Description SegmentCollection(java.util.NavigableMap<java.lang.Double,SegmentWithRange> segments)Creates a new instance of the SegmentCollection class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)booleanequals(java.lang.Object o)SegmentgetSegmentForKey(double key)SegmentgetSegmentForKey(java.lang.String key)java.util.Collection<Segment>getSegments()inthashCode()protected abstract doublehashToRange(java.lang.String key)java.lang.StringtoString()
-
-
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-