Skip to content

Commit 67ab85e

Browse files
guojn1ketor
authored andcommitted
[fix][dingo-sdk] Correct unit testing errors
1 parent d0b792e commit 67ab85e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

java/dingo-sdk/src/main/java/io/dingodb/sdk/common/AutoIncrement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public synchronized long inc() {
4646
return current;
4747
}
4848

49+
public synchronized void init() {
50+
if (inc >= limit) {
51+
fetch();
52+
}
53+
}
54+
4955
public synchronized void inc(long targetInc) {
5056
if (targetInc > inc) {
5157
inc = targetInc;

java/dingo-sdk/src/main/java/io/dingodb/sdk/service/meta/AutoIncrementService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void update(DingoCommonId tableId, long incrementId) {
118118
AutoIncrement autoIncrement = innerCache.computeIfAbsent(tableId,
119119
id -> new AutoIncrement(id, increment, offset, this::fetcher));
120120
if (autoIncrement.getLimit() == 0) {
121-
autoIncrement.inc();
121+
autoIncrement.init();
122122
}
123123
if (incrementId < autoIncrement.getLimit() && incrementId >= autoIncrement.current()) {
124124
autoIncrement.inc(incrementId);

java/dingo-sdk/src/test/java/sdk/common/serial/CodecTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void test() throws IOException {
4040
TableDefinition tableDefinition = TableDefinition.builder()
4141
.name("TEST_ENCODE")
4242
.columns(Arrays.asList(c1, c2, c3, c4))
43-
.version(1)
43+
.version(1).codecVersion(2)
4444
.build();
4545

4646
DingoKeyValueCodec codec = DingoKeyValueCodec.of(1, 1L, tableDefinition);
@@ -60,13 +60,13 @@ public void testAdd() throws IOException {
6060
TableDefinition beforeTable = TableDefinition.builder()
6161
.name("TEST_BEFORE")
6262
.columns(Arrays.asList(c1, c2, c3))
63-
.version(1)
63+
.version(1).codecVersion(2)
6464
.build();
6565

6666
TableDefinition afterTable = TableDefinition.builder()
6767
.name("TEST_AFTER")
6868
.columns(Arrays.asList(c1, c2, c3, c4))
69-
.version(2)
69+
.version(2).codecVersion(2)
7070
.build();
7171

7272
Object[] beforeRecord = {"id1_1", true, 1.02};
@@ -98,13 +98,13 @@ public void testRemove() throws IOException {
9898
TableDefinition beforeTable = TableDefinition.builder()
9999
.name("TEST_BEFORE")
100100
.columns(Arrays.asList(c1, c2, c3, c4))
101-
.version(1)
101+
.version(1).codecVersion(2)
102102
.build();
103103

104104
TableDefinition afterTable = TableDefinition.builder()
105105
.name("TEST_AFTER")
106106
.columns(Arrays.asList(c1, c2, c3))
107-
.version(2)
107+
.version(2).codecVersion(2)
108108
.build();
109109

110110
Object[] beforeRecord = {"id1_1", true, 1.02, 123L};

0 commit comments

Comments
 (0)