Package me.ahoo.cosid.sharding
Class CachedSharding<T extends Comparable<?>>
java.lang.Object
me.ahoo.cosid.sharding.CachedSharding<T>
- Type Parameters:
T- the type of comparable sharding value
- All Implemented Interfaces:
PreciseSharding<T>,RangeSharding<T>,Sharding<T>
Caching wrapper for sharding algorithms.
Caches range sharding results to reduce computation overhead for frequently accessed ranges.
-
Constructor Summary
ConstructorsConstructorDescriptionCachedSharding(Sharding<T> actual) Creates a cached wrapper around the specified sharding algorithm. -
Method Summary
Modifier and TypeMethodDescription@NonNull Collection<String>Gets all effective node names.@NonNull Collection<String>Gets the nodes that should handle the given range of IDs.@NonNull StringGets the node for a single sharding value.
-
Constructor Details
-
CachedSharding
Creates a cached wrapper around the specified sharding algorithm.- Parameters:
actual- the underlying sharding algorithm
-
-
Method Details
-
sharding
Description copied from interface:PreciseShardingGets the node for a single sharding value.- Specified by:
shardingin interfacePreciseSharding<T extends Comparable<?>>- Parameters:
shardingValue- the sharding value- Returns:
- the node name
-
sharding
Description copied from interface:RangeShardingGets the nodes that should handle the given range of IDs.- Specified by:
shardingin interfaceRangeSharding<T extends Comparable<?>>- Parameters:
shardingValue- the range of sharding values- Returns:
- collection of node names that should handle the range
-
getEffectiveNodes
Description copied from interface:ShardingGets all effective node names.- Specified by:
getEffectiveNodesin interfaceSharding<T extends Comparable<?>>- Returns:
- collection of effective node names
-