|
18 | 18 | import com.google.common.base.Splitter.MapSplitter; |
19 | 19 | import com.google.common.base.Suppliers; |
20 | 20 | import com.google.common.base.VerifyException; |
21 | | -import com.google.common.cache.CacheBuilder; |
22 | 21 | import com.google.common.collect.ImmutableList; |
23 | 22 | import com.google.common.collect.ImmutableMap; |
24 | 23 | import com.google.common.collect.ImmutableSet; |
25 | 24 | import com.google.common.collect.Iterables; |
26 | 25 | import com.google.common.collect.Lists; |
27 | 26 | import com.google.common.collect.Sets; |
28 | 27 | import com.google.common.collect.Streams; |
29 | | -import com.google.common.util.concurrent.UncheckedExecutionException; |
30 | 28 | import io.airlift.json.JsonCodec; |
31 | 29 | import io.airlift.log.Logger; |
32 | 30 | import io.airlift.slice.Slice; |
33 | 31 | import io.airlift.slice.Slices; |
34 | 32 | import io.airlift.units.DataSize; |
35 | 33 | import io.airlift.units.Duration; |
36 | | -import io.trino.cache.NonEvictableCache; |
37 | 34 | import io.trino.filesystem.Location; |
38 | 35 | import io.trino.filesystem.TrinoFileSystem; |
39 | 36 | import io.trino.metastore.Column; |
|
247 | 244 |
|
248 | 245 | import static com.google.common.base.Preconditions.checkArgument; |
249 | 246 | import static com.google.common.base.Preconditions.checkState; |
250 | | -import static com.google.common.base.Throwables.throwIfUnchecked; |
251 | 247 | import static com.google.common.base.Verify.verify; |
252 | 248 | import static com.google.common.base.Verify.verifyNotNull; |
253 | 249 | import static com.google.common.collect.ImmutableList.toImmutableList; |
|
258 | 254 | import static com.google.common.collect.Maps.transformValues; |
259 | 255 | import static com.google.common.collect.Sets.difference; |
260 | 256 | import static io.airlift.units.Duration.ZERO; |
261 | | -import static io.trino.cache.CacheUtils.uncheckedCacheGet; |
262 | | -import static io.trino.cache.SafeCaches.buildNonEvictableCache; |
263 | 257 | import static io.trino.filesystem.Locations.isS3Tables; |
264 | 258 | import static io.trino.plugin.base.filter.UtcConstraintExtractor.extractTupleDomain; |
265 | 259 | import static io.trino.plugin.base.projection.ApplyProjectionUtil.extractSupportedProjectedColumns; |
@@ -512,7 +506,7 @@ public class IcebergMetadata |
512 | 506 | private final int materializedViewRefreshMaxSnapshotsToExpire; |
513 | 507 | private final Duration materializedViewRefreshSnapshotRetentionPeriod; |
514 | 508 | private final Map<IcebergTableHandle, AtomicReference<TableStatistics>> tableStatisticsCache = new ConcurrentHashMap<>(); |
515 | | - private final NonEvictableCache<SchemaTableName, IcebergTableCredentials> tableCredentialsCache; |
| 509 | + private final IcebergTableCredentialsProvider tableCredentialsProvider; |
516 | 510 | private final DeletionVectorWriter deletionVectorWriter; |
517 | 511 |
|
518 | 512 | private Transaction transaction; |
@@ -552,42 +546,25 @@ public IcebergMetadata( |
552 | 546 | this.deletionVectorWriter = requireNonNull(deletionVectorWriter, "deletionVectorWriter is null"); |
553 | 547 | this.materializedViewRefreshMaxSnapshotsToExpire = materializedViewRefreshMaxSnapshotsToExpire; |
554 | 548 | this.materializedViewRefreshSnapshotRetentionPeriod = materializedViewRefreshSnapshotRetentionPeriod; |
555 | | - this.tableCredentialsCache = buildNonEvictableCache(CacheBuilder.newBuilder()); |
| 549 | + this.tableCredentialsProvider = new IcebergTableCredentialsProvider(catalog); |
556 | 550 | } |
557 | 551 |
|
558 | 552 | @Override |
559 | 553 | public Optional<ConnectorTableCredentials> getTableCredentials(ConnectorSession session, ConnectorTableHandle tableHandle) |
560 | 554 | { |
561 | | - return getOrLoadTableCredentials(session, getSchemaTableName(tableHandle)); |
| 555 | + return tableCredentialsProvider.getTableCredentials(session, getSchemaTableName(tableHandle)); |
562 | 556 | } |
563 | 557 |
|
564 | 558 | @Override |
565 | 559 | public Optional<ConnectorTableCredentials> getTableCredentials(ConnectorSession session, ConnectorWritableTableHandle tableHandle) |
566 | 560 | { |
567 | | - return getOrLoadTableCredentials(session, getSchemaTableName(tableHandle)); |
| 561 | + return tableCredentialsProvider.getTableCredentials(session, getSchemaTableName(tableHandle)); |
568 | 562 | } |
569 | 563 |
|
570 | 564 | @Override |
571 | 565 | public Optional<ConnectorTableCredentials> getTableCredentials(ConnectorSession session, ConnectorTableFunctionHandle tableFunctionHandle) |
572 | 566 | { |
573 | | - return getOrLoadTableCredentials(session, getSchemaTableName(tableFunctionHandle)); |
574 | | - } |
575 | | - |
576 | | - private Optional<ConnectorTableCredentials> getOrLoadTableCredentials(ConnectorSession session, SchemaTableName schemaTableName) |
577 | | - { |
578 | | - try { |
579 | | - return Optional.of(uncheckedCacheGet( |
580 | | - tableCredentialsCache, |
581 | | - schemaTableName, |
582 | | - () -> { |
583 | | - BaseTable baseTable = catalog.loadTable(session, schemaTableName); |
584 | | - return new IcebergTableCredentials(baseTable.io().properties()); |
585 | | - })); |
586 | | - } |
587 | | - catch (UncheckedExecutionException e) { |
588 | | - throwIfUnchecked(e.getCause()); |
589 | | - throw e; |
590 | | - } |
| 567 | + return tableCredentialsProvider.getTableCredentials(session, getSchemaTableName(tableFunctionHandle)); |
591 | 568 | } |
592 | 569 |
|
593 | 570 | private static SchemaTableName getSchemaTableName(ConnectorTableHandle tableHandle) |
@@ -1599,7 +1576,7 @@ private List<String> getChildNamespaces(ConnectorSession session, String parentN |
1599 | 1576 |
|
1600 | 1577 | private IcebergWritableTableHandle newWritableTableHandle(SchemaTableName name, Table table) |
1601 | 1578 | { |
1602 | | - tableCredentialsCache.put(name, IcebergTableCredentials.forFileIO(table.io())); |
| 1579 | + tableCredentialsProvider.putTableCredentials(name, IcebergTableCredentials.forFileIO(table.io())); |
1603 | 1580 | SortFieldInfo sortInfo = getSupportedSortFields(table.schema(), table.sortOrder()); |
1604 | 1581 | return new IcebergWritableTableHandle( |
1605 | 1582 | name, |
|
0 commit comments