Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
b17c85e3
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b17c85e3
编写于
2月 15, 2017
作者:
G
gaohongtao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #225 ID's sequence can not reset to zero
上级
036df561
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
18 deletion
+6
-18
sharding-jdbc-doc/content/03-community/release-notes.md
sharding-jdbc-doc/content/03-community/release-notes.md
+1
-0
sharding-jdbc-id-generator-parent/sharding-jdbc-self-id-generator/src/main/java/com/dangdang/ddframe/rdb/sharding/id/generator/self/CommonSelfIdGenerator.java
...rdb/sharding/id/generator/self/CommonSelfIdGenerator.java
+1
-10
sharding-jdbc-id-generator-parent/sharding-jdbc-self-id-generator/src/test/java/com/dangdang/ddframe/rdb/sharding/id/generator/self/CommonSelfIdGeneratorTest.java
...sharding/id/generator/self/CommonSelfIdGeneratorTest.java
+4
-8
未找到文件。
sharding-jdbc-doc/content/03-community/release-notes.md
浏览文件 @
b17c85e3
...
...
@@ -20,6 +20,7 @@ next = "/03-community/directory-structure"
1.
[
ISSUE #212
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/212
)
对去缺少数据源规则给出更有意义的提示
1.
[
ISSUE #214
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/214
)
where中 table_name.column_name in (?,?)无法解析表达式
1.
[
ISSUE #180
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/180
)
批量执行Update返回值不准确
1.
[
ISSUE #225
](
https://github.com/dangdangdotcom/sharding-jdbc/issues/225
)
自动生成Id最后一位不归零
## 1.4.1
...
...
sharding-jdbc-id-generator-parent/sharding-jdbc-self-id-generator/src/main/java/com/dangdang/ddframe/rdb/sharding/id/generator/self/CommonSelfIdGenerator.java
浏览文件 @
b17c85e3
...
...
@@ -112,15 +112,6 @@ public class CommonSelfIdGenerator implements IdGenerator {
CommonSelfIdGenerator
.
workerId
=
workerId
;
}
/**
* 获取工作Id的二进制长度.
*
* @return 工作Id的二进制长度
*/
public
static
long
getWorkerIdLength
()
{
return
WORKER_ID_BITS
;
}
/**
* 生成Id.
*
...
...
@@ -131,7 +122,7 @@ public class CommonSelfIdGenerator implements IdGenerator {
long
time
=
clock
.
millis
();
Preconditions
.
checkState
(
lastTime
<=
time
,
"Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds"
,
lastTime
,
time
);
if
(
lastTime
==
time
)
{
if
(
0L
==
(++
sequence
&
SEQUENCE_MASK
))
{
if
(
0L
==
(
sequence
=
++
sequence
&
SEQUENCE_MASK
))
{
time
=
waitUntilNextTime
(
time
);
}
}
else
{
...
...
sharding-jdbc-id-generator-parent/sharding-jdbc-self-id-generator/src/test/java/com/dangdang/ddframe/rdb/sharding/id/generator/self/CommonSelfIdGeneratorTest.java
浏览文件 @
b17c85e3
...
...
@@ -61,20 +61,16 @@ public class CommonSelfIdGeneratorTest {
public
void
testMaxSequence
()
throws
Exception
{
assertThat
(
maxId
((
1
<<
12
)
-
1
),
is
((
1L
<<
12L
)
-
2
));
assertThat
(
maxId
(
1
<<
12
),
is
((
1L
<<
12L
)
-
1
));
assertThat
(
maxId
((
1
<<
12
)
+
1
),
is
((
1L
<<
12L
)
-
1
));
assertThat
(
maxId
(
1
<<
13
),
is
((
1L
<<
12L
)
-
1
));
assertThat
(
maxId
((
1
<<
13
)
+
1
),
is
((
1L
<<
12L
)
-
1
));
assertThat
(
maxId
((
1
<<
12
)
+
1
),
is
(
1L
<<
22
));
}
private
long
maxId
(
final
int
maxSequence
)
{
CommonSelfIdGenerator
idGenerator
=
new
CommonSelfIdGenerator
();
CommonSelfIdGenerator
.
setClock
(
new
FixClock
(
maxSequence
));
CommonSelfIdGenerator
.
setClock
(
new
FixClock
(
1
<<
13
));
long
id
=
0
;
long
preId
=
0
;
while
(
id
<
(
1L
<<
12
))
{
preId
=
id
;
for
(
int
i
=
0
;
i
<
maxSequence
;
i
++)
{
id
=
(
Long
)
idGenerator
.
generateId
();
}
return
preI
d
;
return
i
d
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录