-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
74 additions
and
39 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
|
||
@Value(staticConstructor = "of") | ||
public class Info { | ||
int seq; | ||
String name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
jpa-jdbc/jdbc/src/test/java/org/example/persistence/util/serializer/SerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
package org.example.persistence.util.serializer; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.example.entity.Info; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class SerializerTest { | ||
@Test | ||
void test() { | ||
Info base = Info.of("hello"); | ||
Info base = Info.of(1, "hello"); | ||
String serialized = Serializer.getInstance().serialize(base); | ||
System.out.println("hello = " + serialized); | ||
|
||
Info deserialized = Serializer.getInstance().deserialize(serialized, Info.class); | ||
assertThat(deserialized).isEqualTo(base); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
CREATE TABLE IF NOT EXISTS users | ||
( | ||
id BIGINT PRIMARY KEY, | ||
name VARCHAR(25) NOT NULL, | ||
info json NOT NULL, | ||
id BIGINT PRIMARY KEY, | ||
name VARCHAR(25) NOT NULL, | ||
info json NOT NULL, | ||
|
||
version INT NOT NULL | ||
); | ||
version INT NOT NULL, | ||
add_offset INT NOT NULL, | ||
publish_offset INT NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
@Value(staticConstructor = "of") | ||
@ToString | ||
public class Info { | ||
Integer seq; | ||
String name; | ||
} |
16 changes: 12 additions & 4 deletions
16
jpa-jdbc/jdbc2/src/main/java/org/example/entity/Infos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
package org.example.entity; | ||
|
||
import java.util.List; | ||
import lombok.Value; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Value(staticConstructor = "of") | ||
public class Infos { | ||
List<Info> infos; | ||
|
||
public String pop() { | ||
public List<String> pop(int startOffset, int publishOffset) { | ||
if (infos.isEmpty()) { | ||
return "empty"; | ||
return new LinkedList<>(); | ||
} | ||
Info info = infos.get(0); | ||
infos.remove(0); | ||
return info.toString(); | ||
|
||
return infos.stream().filter( | ||
i -> i.getSeq() > startOffset | ||
&& info.getSeq() <= publishOffset | ||
).map(Info::toString) | ||
.collect(Collectors.toUnmodifiableList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters