cosid-shardinglisted
Install: claude install-skill Ahoo-Wang/skills
# Design CosId Sharding
Treat core Java sharding APIs and ShardingSphere configuration as separate integration surfaces. Verify the target CosId and ShardingSphere versions before copying property names.
## Workflow
1. Identify the sharding key type and every query operator that must route: exact, `IN`, and range.
2. Define physical nodes, naming, bounds, and future partition provisioning before selecting an algorithm.
3. Choose `ModCycle` for fixed-count numeric distribution or `IntervalTimeline` for time partitions.
4. Add Snowflake conversion only when the ID layout is known and aligned with the parser.
5. Build a routing matrix that covers boundaries, out-of-range values, and full-range queries.
## Core Algorithms
| API | Use | Important behavior |
|---|---|---|
| `ModCycle<T>` | Fixed number of numeric nodes | Exact route is `value % divisor`; current implementation requires non-negative values |
| `IntervalTimeline` | Bounded `LocalDateTime` partitions | Exact values outside the effective interval throw `IllegalArgumentException` |
| `SnowflakeLocalDateTimeConvertor` | Convert Snowflake `Long` or radix-62 `String` to time | Parser must match the generator epoch and bit layout |
| `CachedSharding<T>` | Reuse identical range results | `@Beta` and backed by an unbounded cache; use only for demonstrably low-cardinality repeated ranges |
### Modulo Example
```java
ModCycle<Long> sharding = new ModCycle<>(4, "t_order_");
String exact = sharding.sharding(42L); // t_ord