Skip to content

Commit

Permalink
ensure new transactions and stamps are only created if they don't alr… (
Browse files Browse the repository at this point in the history
#17)

* ensure new transactions and stamps are only created if they don't already exist

* composer transaction to local variable

* update tinkar-core and eclipse-collections versions

* fix tinkar core version typo
  • Loading branch information
rbradley813 authored Oct 17, 2024
1 parent 06612a2 commit 9ef8a01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
</organization>

<properties>
<tinkar-core.version>1.72.0</tinkar-core.version>
<tinkar-core.version>1.74.0</tinkar-core.version>
<slf4j.version>2.0.13</slf4j.version>
<log4j.version>3.0.0-alpha1</log4j.version>
<tinkar-starter-data.version>1.0.0</tinkar-starter-data.version>

<!-- JPMS Dependencies -->
<tinkar-jpms-deps.groupId>dev.ikm.jpms</tinkar-jpms-deps.groupId>
<eclipse-collections.version>11.1.0-r12</eclipse-collections.version>
<eclipse-collections.version>11.1.0-r13</eclipse-collections.version>
<eclipse-collections-api.version>11.1.0-r11</eclipse-collections-api.version>
</properties>

Expand Down
19 changes: 11 additions & 8 deletions src/main/java/dev/ikm/tinkar/composer/Composer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
public class Composer {
private final Map<UUID, Session> composerSessionCache = new HashMap<>();
private StampEntity stampEntity;
private Transaction transaction;
private final String name;

public Composer(String name) {
Expand All @@ -54,10 +53,12 @@ public Composer(String name) {
* @see State
*/
public Session open(State status, long time, Concept author, Concept module, Concept path) {
this.transaction = new Transaction(name);
this.stampEntity = transaction.getStamp(status, time, author.publicId(), module.publicId(), path.publicId());
UUID sessionKey = keyValue(status, time, author, module, path);
composerSessionCache.computeIfAbsent(sessionKey, (key) -> new Session(transaction, stampEntity, sessionKey));
composerSessionCache.computeIfAbsent(sessionKey, (key) -> {
Transaction transaction = new Transaction(name);
this.stampEntity = transaction.getStamp(status, time, author.publicId(), module.publicId(), path.publicId());
return new Session(transaction, stampEntity, sessionKey);
});
return composerSessionCache.get(sessionKey);
}

Expand All @@ -80,10 +81,12 @@ public Session open(State status, long time, Concept author, Concept module, Con
* @see State
*/
public Session open(State status, Concept author, Concept module, Concept path) {
this.transaction = new Transaction(name);
this.stampEntity = transaction.getStamp(status, author, module, path);
UUID sessionKey = keyValue(status, transaction.commitTime(), author, module, path);
composerSessionCache.computeIfAbsent(sessionKey, (key) -> new Session(transaction, stampEntity, sessionKey));
UUID sessionKey = keyValue(status, Long.MAX_VALUE, author, module, path);
composerSessionCache.computeIfAbsent(sessionKey, (key) -> {
Transaction transaction = new Transaction(name);
this.stampEntity = transaction.getStamp(status, author, module, path);
return new Session(transaction, stampEntity, sessionKey);
});
return composerSessionCache.get(sessionKey);
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
requires org.junit.jupiter.api;
requires dev.ikm.jpms.eclipse.collections.api;



exports dev.ikm.tinkar.composer.test;
exports dev.ikm.tinkar.composer.test.template;

Expand Down

0 comments on commit 9ef8a01

Please sign in to comment.