Skip to content

Commit e561b23

Browse files
committed
Improved loading speed of data model extensions
1 parent 9d6e84f commit e561b23

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ static final Moment parseMoment(String value) {
141141
private DSLContext dslContext;
142142
private String schemaPriority;
143143

144+
private final Map<Name, Table<?>> tableCache = new HashMap<>();
145+
144146
/**
145147
* Tracker for the amount of data fetched form the DB by this PM.
146148
*/
@@ -708,6 +710,10 @@ public Table<?> getDbTable(String tableName) {
708710

709711
@Override
710712
public Table<?> getDbTable(Name tableName) {
713+
return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName));
714+
}
715+
716+
public Table<?> readDbTableFromDb(Name tableName) {
711717
final Meta meta = dslContext.meta();
712718
final List<Table<?>> tables = meta.getTables(tableName);
713719
if (tables.isEmpty()) {

FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ static final Moment parseMoment(String value) {
141141
private DSLContext dslContext;
142142
private String schemaPriority;
143143

144+
private final Map<Name, Table<?>> tableCache = new HashMap<>();
145+
144146
/**
145147
* Tracker for the amount of data fetched form the DB by this PM.
146148
*/
@@ -703,6 +705,10 @@ public Table<?> getDbTable(String tableName) {
703705

704706
@Override
705707
public Table<?> getDbTable(Name tableName) {
708+
return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName));
709+
}
710+
711+
public Table<?> readDbTableFromDb(Name tableName) {
706712
final Meta meta = dslContext.meta();
707713
final List<Table<?>> tables = meta.getTables(tableName);
708714
if (tables.isEmpty()) {

0 commit comments

Comments
 (0)