pvary commented on code in PR #14406:
URL: https://github.com/apache/iceberg/pull/14406#discussion_r2588179582
##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableMetadataCache.java:
##########
@@ -50,13 +51,19 @@ class TableMetadataCache {
private final Catalog catalog;
private final long refreshMs;
+ private final Clock cacheRefreshClock;
private final int inputSchemasPerTableCacheMaximumSize;
private final Map<TableIdentifier, CacheItem> tableCache;
TableMetadataCache(
- Catalog catalog, int maximumSize, long refreshMs, int
inputSchemasPerTableCacheMaximumSize) {
+ Catalog catalog,
+ int maximumSize,
+ long refreshMs,
+ Clock cacheRefreshClock,
Review Comment:
We don't have dependency injection in the Iceberg library. The main reason
is that we don't want the users to use a specific one.
Since we don't have a way to inject the clock, I still think we could create
a specific constructor for testing:
```
TableMetadataCache(
Catalog catalog, int maximumSize, long refreshMs, int
inputSchemasPerTableCacheMaximumSize) {
this(catalog, maximumSize, refreshMs,
inputSchemasPerTableCacheMaximumSize, Clock.systemUTC());
}
@VisibleForTesting
TableMetadataCache(
Catalog catalog, int maximumSize, long refreshMs, int
inputSchemasPerTableCacheMaximumSize, Clock cacheRefreshClock) {
this.catalog = catalog;
this.refreshMs = refreshMs;
this.inputSchemasPerTableCacheMaximumSize =
inputSchemasPerTableCacheMaximumSize;
this.tableCache = new LRUCache<>(maximumSize);
this.cacheRefreshClock = cacheRefreshClock;
}
```
If we do this way, we only need to add a new test method, and don't need the
other changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]