Releases: Ahoo-Wang/CosId
Releases · Ahoo-Wang/CosId
v1.4.8
- Enhancement: add
ExactCollection
, mainly for scenarios where Interval sharding algorithm and Mod sharding algorithm can predict the number of nodes in advance. Improve performance and memory utilization. - Add:
CosIdModShardingAlgorithm
to re implement the module sharding algorithm and improve performance.
- Add:JMH
ModShardingAlgorithmBenchmark
,CosIdModShardingAlgorithm
VSorg.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm
PreciseShardingValue | RangeShardingValue |
---|---|
- 增强:新增
ExactCollection
(准确式集合),主要针对 Interval 分片算法、Mod 分片算法可以提前预知节点数量的场景。提升性能与内存利用率。 - 新增:
CosIdModShardingAlgorithm
以重新实现取模分片算法,提升性能。
- 新增:基准测试
ModShardingAlgorithmBenchmark
,CosIdModShardingAlgorithm
VSorg.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm
PreciseShardingValue | RangeShardingValue |
---|---|
v1.4.6
v1.4.5
- add
CosIdIntervalShardingAlgorithm
to implementorg.apache.shardingsphere.sharding.spi.ShardingAlgorithm
to improve the performance and ease of use
- Ease of use: supports multiple data types (
Long
/LocalDateTime
/Date
),The official implementation is to first convert to a string and then convert toLocalDateTime
, the conversion success rate is affected by the time formatting characters. - Performance: Compared to
org.apache.shardingsphere.sharding.algorithm.sharding.datetime.IntervalShardingAlgorithm
,The performance is 1200~4000 times higher.
- Ease of use: supports multiple data types (
- Interval-based time range sharding algorithm
DateIntervalShardingAlgorithm
(COSID_INTERVAL_DATE)LocalDateTimeIntervalShardingAlgorithm
(COSID_INTERVAL_LDT)SnowflakeIntervalShardingAlgorithm
(COSID_INTERVAL_SNOWFLAKE)TimestampIntervalShardingAlgorithm
(COSID_INTERVAL_TS)TimestampOfSecondIntervalShardingAlgorithm
(COSID_INTERVAL_TS_SECOND)
spring:
shardingsphere:
rules:
sharding:
sharding-algorithms:
alg-name:
type: COSID_INTERVAL_{type_suffix}
props:
logic-name: logic-name
id-name: cosid-name
datetime-lower: 2021-12-08T22:00:00
datetime-upper: 2022-12-01T00:00:00
sharding-suffix-pattern: _yyyyMM
datetime-interval-unit: MONTHS
datetime-interval-amount: 1
- add JMH test for
CosIdIntervalShardingAlgorithm
VSorg.apache.shardingsphere.sharding.algorithm.sharding.datetime.IntervalShardingAlgorithm
gradle cosid-shardingsphere:jmh
# JMH version: 1.29
# VM version: JDK 11.0.13, OpenJDK 64-Bit Server VM, 11.0.13+8-LTS
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/work/CosId/cosid-shardingsphere/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
# Warmup: 1 iterations, 10 s each
# Measurement: 1 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
Benchmark Mode Cnt Score Error Units
IntervalShardingAlgorithmBenchmark.cosid_precise_local_date_time thrpt 66276995.822 ops/s
IntervalShardingAlgorithmBenchmark.cosid_precise_timestamp thrpt 24841952.001 ops/s
IntervalShardingAlgorithmBenchmark.cosid_range_local_date_time thrpt 3344013.803 ops/s
IntervalShardingAlgorithmBenchmark.cosid_range_timestamp thrpt 2846453.298 ops/s
IntervalShardingAlgorithmBenchmark.office_precise_timestamp thrpt 6286.861 ops/s
IntervalShardingAlgorithmBenchmark.office_range_timestamp thrpt 2302.986 ops/s
- Open interface
SnowflakeFriendlyId.getParser
- fix
JdbcIdSegmentInitializer
construction parameter error(CosIdJdbcSegmentAutoConfiguration,jdbcIdSegmentInitializer
)
- 新增
CosIdIntervalShardingAlgorithm
实现org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
以提升INTERVAL
性能与易用性
-
易用性: 原生支持多种数据类型 (
Long
、LocalDateTime
、Date
),而官方实现是先转换成字符串再转换成LocalDateTime
,转换成功率受时间格式化字符影响。 -
性能 : 相比于官方实现
org.apache.shardingsphere.sharding.algorithm.sharding.datetime.IntervalShardingAlgorithm
性能至少高出 1200~4000 倍。
-
基于间隔的时间范围分片算法
-
DateIntervalShardingAlgorithm
(COSID_INTERVAL_DATE) -
LocalDateTimeIntervalShardingAlgorithm
(COSID_INTERVAL_LDT) -
SnowflakeIntervalShardingAlgorithm
(COSID_INTERVAL_SNOWFLAKE) -
TimestampIntervalShardingAlgorithm
(COSID_INTERVAL_TS) -
TimestampOfSecondIntervalShardingAlgorithm
(COSID_INTERVAL_TS_SECOND)
-
spring:
shardingsphere:
rules:
sharding:
sharding-algorithms:
alg-name:
type: COSID_INTERVAL_{type_suffix}
props:
logic-name: logic-name
id-name: cosid-name
datetime-lower: 2021-12-08T22:00:00
datetime-upper: 2022-12-01T00:00:00
sharding-suffix-pattern: _yyyyMM
datetime-interval-unit: MONTHS
datetime-interval-amount: 1
- 新增基准测试
CosIdIntervalShardingAlgorithm
VSorg.apache.shardingsphere.sharding.algorithm.sharding.datetime.IntervalShardingAlgorithm
gradle cosid-shardingsphere:jmh
# JMH version: 1.29
# VM version: JDK 11.0.13, OpenJDK 64-Bit Server VM, 11.0.13+8-LTS
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/work/CosId/cosid-shardingsphere/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
# Warmup: 1 iterations, 10 s each
# Measurement: 1 iterations, 10 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
Benchmark Mode Cnt Score Error Units
IntervalShardingAlgorithmBenchmark.cosid_precise_local_date_time thrpt 66276995.822 ops/s
IntervalShardingAlgorithmBenchmark.cosid_precise_timestamp thrpt 24841952.001 ops/s
IntervalShardingAlgorithmBenchmark.cosid_range_local_date_time thrpt 3344013.803 ops/s
IntervalShardingAlgorithmBenchmark.cosid_range_timestamp thrpt 2846453.298 ops/s
IntervalShardingAlgorithmBenchmark.office_precise_timestamp thrpt 6286.861 ops/s
IntervalShardingAlgorithmBenchmark.office_range_timestamp thrpt 2302.986 ops/s
- API调整: 开放接口
SnowflakeFriendlyId.getParser
- 修复: JdbcIdSegmentInitializer 构造函数赋值错误问题 #I4LVBZ (CosIdJdbcSegmentAutoConfiguration,jdbcIdSegmentInitializer)
v1.4.0
add CosIdKeyGenerateAlgorithm
to support org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
(cosid-shardingsphere)
Kotlin DSL
implementation("me.ahoo.cosid:cosid-shardingsphere:${cosidVersion}")
spring:
shardingsphere:
rules:
sharding:
key-generators:
cosid:
type: COSID
props:
id-name: __share__