snazy commented on code in PR #2029:
URL: https://github.com/apache/polaris/pull/2029#discussion_r2204493719
##########
polaris-core/src/main/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheKey.java:
##########
@@ -18,118 +18,45 @@
*/
package org.apache.polaris.core.storage.cache;
-import java.util.Objects;
+import jakarta.annotation.Nullable;
import java.util.Set;
import org.apache.polaris.core.entity.PolarisEntity;
import org.apache.polaris.core.entity.PolarisEntityConstants;
+import org.apache.polaris.immutables.PolarisImmutable;
-public class StorageCredentialCacheKey {
+@PolarisImmutable
+public interface StorageCredentialCacheKey {
- private final String realmId;
- private final long catalogId;
+ String realmId();
- /** The serialized string of the storage config. */
- private final String storageConfigSerializedStr;
+ long catalogId();
- /**
- * The entity id is passed to be used to fetch subscoped creds, but is not
used to do hash/equals
- * as part of the cache key.
- */
- private final long entityId;
+ @Nullable
+ String storageConfigSerializedStr();
- private final boolean allowedListAction;
- private final Set<String> allowedReadLocations;
+ boolean allowedListAction();
- private final Set<String> allowedWriteLocations;
+ Set<String> allowedReadLocations();
- public StorageCredentialCacheKey(
+ Set<String> allowedWriteLocations();
+
+ static StorageCredentialCacheKey of(
String realmId,
PolarisEntity entity,
boolean allowedListAction,
Set<String> allowedReadLocations,
Set<String> allowedWriteLocations) {
- this.realmId = realmId;
- this.catalogId = entity.getCatalogId();
- this.storageConfigSerializedStr =
+ String storageConfigSerializedStr =
entity
.getInternalPropertiesAsMap()
.get(PolarisEntityConstants.getStorageConfigInfoPropertyName());
- this.entityId = entity.getId();
- this.allowedListAction = allowedListAction;
- this.allowedReadLocations = allowedReadLocations;
- this.allowedWriteLocations = allowedWriteLocations;
- }
-
- public String getRealmId() {
- return realmId;
- }
-
- public long getCatalogId() {
- return catalogId;
- }
-
- public String getStorageConfigSerializedStr() {
- return storageConfigSerializedStr;
- }
-
- public long getEntityId() {
- return entityId;
- }
-
- public boolean isAllowedListAction() {
- return allowedListAction;
- }
-
- public Set<String> getAllowedReadLocations() {
- return allowedReadLocations;
- }
-
- public Set<String> getAllowedWriteLocations() {
- return allowedWriteLocations;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- StorageCredentialCacheKey cacheKey = (StorageCredentialCacheKey) o;
- return Objects.equals(realmId, cacheKey.getRealmId())
- && catalogId == cacheKey.getCatalogId()
- && Objects.equals(storageConfigSerializedStr,
cacheKey.getStorageConfigSerializedStr())
- && allowedListAction == cacheKey.allowedListAction
- && Objects.equals(allowedReadLocations, cacheKey.allowedReadLocations)
- && Objects.equals(allowedWriteLocations,
cacheKey.allowedWriteLocations);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- realmId,
- catalogId,
- storageConfigSerializedStr,
- allowedListAction,
- allowedReadLocations,
- allowedWriteLocations);
- }
-
- @Override
- public String toString() {
- return "StorageCredentialCacheKey{"
- + "realmId="
- + realmId
- + ", catalogId="
- + catalogId
- + ", storageConfigSerializedStr='"
- + storageConfigSerializedStr
- + '\''
- + ", entityId="
- + entityId
- + ", allowedListAction="
- + allowedListAction
- + ", allowedReadLocations="
- + allowedReadLocations
- + ", allowedWriteLocations="
- + allowedWriteLocations
- + '}';
+ return ImmutableStorageCredentialCacheKey.builder()
Review Comment:
Why not delegate to the existing
`ImmutableStorageCredentialCacheKey.of(...)` ?
--
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]