你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ShardRange Class

  • java.lang.Object
    • Comparable<ShardRange>
      • com.microsoft.azure.elasticdb.shard.base.ShardRange

public class ShardRange

A range of shard keys between a low key and a high key. The low key is inclusive (part of the range) while the high key is exclusive (not part of the range). The ShardRange class is immutable.

Field Summary

Modifier and Type Field and Description
final ShardRange NULL

Constructor Summary

Constructor Description
ShardRange()
ShardRange(ShardKey low, ShardKey high)

Constructs a shard range from low boundary (inclusive) to high high boundary (exclusive).

Method Summary

Modifier and Type Method and Description
int compareTo(ShardRange other)

Performs comparison between two shard range values.

boolean contains(ShardKey key)

Checks whether the specified key is inside the range.

boolean contains(ShardRange range)

Checks whether the range is inside the range.

boolean equals(Object obj)

Determines whether the specified object is equal to the current object.

boolean equals(ShardRange other)

Performs equality comparison with another given ShardRange.

ShardRange getFullRange(ShardKeyType keyType)

Gets a shard range corresponding to a specified key type.

ShardRange getFullRangeBinary()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeDateTime()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeDateTimeOffset()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeGuid()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeInt32()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeInt64()

Full range that starts from the min value for a key to the max value.

ShardRange getFullRangeTimeSpan()

Full range that starts from the min value for a key to the max value.

ShardKey getHigh()
ShardKeyType getKeyType()
ShardKey getLow()
int hashCode()

Calculates the hash code for this instance.

ShardRange intersect(ShardRange range)

Returns the intersection of two ranges.

boolean intersects(ShardRange range)

Checks whether the range intersects with the current range.

boolean opEquality(ShardRange left, ShardRange right)

Equality operator.

boolean opGreaterThan(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (greater than).

boolean opGreaterThanOrEqual(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (greater or equal).

boolean opInequality(ShardRange left, ShardRange right)

Inequality operator.

boolean opLessThan(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (less than).

boolean opLessThanOrEqual(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (less or equal).

String toString()

Converts the object to its string representation.

Field Details

NULL

public static final ShardRange NULL= new ShardRange()

Constructor Details

ShardRange

public ShardRange()

ShardRange

public ShardRange(ShardKey low, ShardKey high)

Constructs a shard range from low boundary (inclusive) to high high boundary (exclusive).

Parameters:

low - low boundary (inclusive)
high - high boundary (exclusive)

Method Details

compareTo

public int compareTo(ShardRange other)

Performs comparison between two shard range values.

Parameters:

other - The shard range compared with this object.

Returns:

-1 : if this range's low boundary is less than the other 's low boundary; -1 : if the low boundary values match and the high boundary value of this range is less than the other 's. 1 : if this range's high boundary is greater than the other 's high boundary; 1 : if the low boundary value of this range is higher than other 's low boundary and high boundary value of this range is less than or equal to other 's high boundary . 0 : if this range has the same boundaries as other .

contains

public boolean contains(ShardKey key)

Checks whether the specified key is inside the range.

Parameters:

key - The key to check

Returns:

True if inside, false otherwise

contains

public boolean contains(ShardRange range)

Checks whether the range is inside the range.

Parameters:

range - The range to check.

Returns:

True if inside, false otherwise.

equals

public boolean equals(Object obj)

Determines whether the specified object is equal to the current object.

Parameters:

obj - The object to compare with the current object.

Returns:

True if the specified object is equal to the current object; otherwise, false.

equals

public boolean equals(ShardRange other)

Performs equality comparison with another given ShardRange.

Parameters:

other - ShardRange to compare with.

Returns:

True if same shard range, false otherwise.

getFullRange

public static ShardRange getFullRange(ShardKeyType keyType)

Gets a shard range corresponding to a specified key type.

Parameters:

keyType - Type of key.

Returns:

Full range for given key type.

getFullRangeBinary

public static ShardRange getFullRangeBinary()

Full range that starts from the min value for a key to the max value.

getFullRangeDateTime

public static ShardRange getFullRangeDateTime()

Full range that starts from the min value for a key to the max value.

getFullRangeDateTimeOffset

public static ShardRange getFullRangeDateTimeOffset()

Full range that starts from the min value for a key to the max value.

getFullRangeGuid

public static ShardRange getFullRangeGuid()

Full range that starts from the min value for a key to the max value.

getFullRangeInt32

public static ShardRange getFullRangeInt32()

Full range that starts from the min value for a key to the max value.

getFullRangeInt64

public static ShardRange getFullRangeInt64()

Full range that starts from the min value for a key to the max value.

getFullRangeTimeSpan

public static ShardRange getFullRangeTimeSpan()

Full range that starts from the min value for a key to the max value.

getHigh

public ShardKey getHigh()

getKeyType

public ShardKeyType getKeyType()

getLow

public ShardKey getLow()

hashCode

public int hashCode()

Calculates the hash code for this instance.

Returns:

Hash code for the object.

intersect

public ShardRange intersect(ShardRange range)

Returns the intersection of two ranges.

Parameters:

range - Range to intersect with.

Returns:

The intersection of the current range and the specified range, null if ranges dont intersect.

intersects

public boolean intersects(ShardRange range)

Checks whether the range intersects with the current range.

Parameters:

range - The range to check.

Returns:

True if it intersects, False otherwise.

opEquality

public static boolean opEquality(ShardRange left, ShardRange right)

Equality operator.

Parameters:

left - Left hand side
right - Right hand side

Returns:

True if the two objects are equal, false in all other cases

opGreaterThan

public static boolean opGreaterThan(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (greater than).

Parameters:

left - Left hand side ShardRange of the operator.
right - Right hand side ShardRange of the operator.

Returns:

True if lhs> rhs

opGreaterThanOrEqual

public static boolean opGreaterThanOrEqual(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (greater or equal).

Parameters:

left - Left hand side ShardRange of the operator.
right - Right hand side ShardRange of the operator.

Returns:

True if lhs>= rhs

opInequality

public static boolean opInequality(ShardRange left, ShardRange right)

Inequality operator.

Parameters:

left - Left hand side
right - Right hand side

Returns:

True if the two objects are not equal, false in all other cases

opLessThan

public static boolean opLessThan(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (less than).

Parameters:

left - Left hand side ShardRange of the operator.
right - Right hand side ShardRange of the operator.

Returns:

True if lhs <rhs

opLessThanOrEqual

public static boolean opLessThanOrEqual(ShardRange left, ShardRange right)

Compares two ShardRange using lexicographic order (less or equal).

Parameters:

left - Left hand side ShardRange of the operator.
right - Right hand side ShardRange of the operator.

Returns:

True if lhs <= rhs

toString

public String toString()

Converts the object to its string representation.

Returns:

String representation of the object.

Applies to