Skip to content

Commit

Permalink
Improved loading speed of data model extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
hylkevds committed Nov 24, 2023
1 parent 9d6e84f commit e561b23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ static final Moment parseMoment(String value) {
private DSLContext dslContext;
private String schemaPriority;

private final Map<Name, Table<?>> tableCache = new HashMap<>();

/**
* Tracker for the amount of data fetched form the DB by this PM.
*/
Expand Down Expand Up @@ -708,6 +710,10 @@ public Table<?> getDbTable(String tableName) {

@Override
public Table<?> getDbTable(Name tableName) {
return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName));
}

public Table<?> readDbTableFromDb(Name tableName) {
final Meta meta = dslContext.meta();
final List<Table<?>> tables = meta.getTables(tableName);
if (tables.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ static final Moment parseMoment(String value) {
private DSLContext dslContext;
private String schemaPriority;

private final Map<Name, Table<?>> tableCache = new HashMap<>();

/**
* Tracker for the amount of data fetched form the DB by this PM.
*/
Expand Down Expand Up @@ -703,6 +705,10 @@ public Table<?> getDbTable(String tableName) {

@Override
public Table<?> getDbTable(Name tableName) {
return tableCache.computeIfAbsent(tableName, (t) -> readDbTableFromDb(tableName));
}

public Table<?> readDbTableFromDb(Name tableName) {
final Meta meta = dslContext.meta();
final List<Table<?>> tables = meta.getTables(tableName);
if (tables.isEmpty()) {
Expand Down

0 comments on commit e561b23

Please sign in to comment.