Skip to content

Commit

Permalink
[fix][dingo-sdk] Correct unit testing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
guojn1 authored and ketor committed Jan 10, 2025
1 parent d0b792e commit 67ab85e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public synchronized long inc() {
return current;
}

public synchronized void init() {
if (inc >= limit) {
fetch();
}
}

public synchronized void inc(long targetInc) {
if (targetInc > inc) {
inc = targetInc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void update(DingoCommonId tableId, long incrementId) {
AutoIncrement autoIncrement = innerCache.computeIfAbsent(tableId,
id -> new AutoIncrement(id, increment, offset, this::fetcher));
if (autoIncrement.getLimit() == 0) {
autoIncrement.inc();
autoIncrement.init();
}
if (incrementId < autoIncrement.getLimit() && incrementId >= autoIncrement.current()) {
autoIncrement.inc(incrementId);
Expand Down
10 changes: 5 additions & 5 deletions java/dingo-sdk/src/test/java/sdk/common/serial/CodecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void test() throws IOException {
TableDefinition tableDefinition = TableDefinition.builder()
.name("TEST_ENCODE")
.columns(Arrays.asList(c1, c2, c3, c4))
.version(1)
.version(1).codecVersion(2)
.build();

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

TableDefinition afterTable = TableDefinition.builder()
.name("TEST_AFTER")
.columns(Arrays.asList(c1, c2, c3, c4))
.version(2)
.version(2).codecVersion(2)
.build();

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

TableDefinition afterTable = TableDefinition.builder()
.name("TEST_AFTER")
.columns(Arrays.asList(c1, c2, c3))
.version(2)
.version(2).codecVersion(2)
.build();

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

0 comments on commit 67ab85e

Please sign in to comment.