You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2025/08/19 15:43:58 UTC
(polaris) branch main updated: Remove BaseMetaStoreManager.serializeProperties (#2374)
This is an automated email from the ASF dual-hosted git repository.
dimas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new a07ea0126 Remove BaseMetaStoreManager.serializeProperties (#2374)
a07ea0126 is described below
commit a07ea01260687d70592bfee18bb4500dfe4bcb22
Author: Christopher Lambert <xn...@gmx.de>
AuthorDate: Tue Aug 19 17:43:55 2025 +0200
Remove BaseMetaStoreManager.serializeProperties (#2374)
similar to 7af85be7f45c933a377314a669e2a16633c93532 we should prefer
the existing helper methods on the entity instead
---
.../AtomicOperationMetaStoreManager.java | 26 ++++------------
.../core/persistence/BaseMetaStoreManager.java | 35 ----------------------
.../TransactionalMetaStoreManagerImpl.java | 26 ++++------------
3 files changed, 10 insertions(+), 77 deletions(-)
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
index c52e9273f..8af4c654d 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
@@ -252,7 +252,7 @@ public class AtomicOperationMetaStoreManager extends BaseMetaStoreManager {
// if it is a principal, we also need to drop the secrets
if (entity.getType() == PolarisEntityType.PRINCIPAL) {
// get internal properties
- Map<String, String> properties = this.deserializeProperties(entity.getInternalProperties());
+ Map<String, String> properties = entity.getInternalPropertiesAsMap();
// get client_id
String clientId = properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -432,7 +432,7 @@ public class AtomicOperationMetaStoreManager extends BaseMetaStoreManager {
// validate input
callCtx.getDiagServices().checkNotNull(catalog, "unexpected_null_catalog");
- Map<String, String> internalProp = getInternalPropertyMap(catalog);
+ Map<String, String> internalProp = catalog.getInternalPropertiesAsMap();
String integrationIdentifierOrId =
internalProp.get(PolarisEntityConstants.getStorageIntegrationIdentifierPropertyName());
String storageConfigInfoStr =
@@ -751,8 +751,7 @@ public class AtomicOperationMetaStoreManager extends BaseMetaStoreManager {
principal);
// get internal properties
- Map<String, String> properties =
- this.deserializeProperties(refreshPrincipal.getInternalProperties());
+ Map<String, String> properties = refreshPrincipal.getInternalPropertiesAsMap();
// get client_id
String clientId = properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -798,14 +797,14 @@ public class AtomicOperationMetaStoreManager extends BaseMetaStoreManager {
.generateNewPrincipalSecrets(callCtx, principal.getName(), principal.getId());
// generate properties
- Map<String, String> internalProperties = getInternalPropertyMap(principal);
+ Map<String, String> internalProperties = principal.getInternalPropertiesAsMap();
internalProperties.put(
PolarisEntityConstants.getClientIdPropertyName(), principalSecrets.getPrincipalClientId());
// remember client id
PolarisBaseEntity updatedPrincipal =
new PolarisBaseEntity.Builder(principal)
- .internalProperties(this.serializeProperties(internalProperties))
+ .internalPropertiesAsMap(internalProperties)
.build();
// now create and persist new catalog entity
EntityResult lowLevelResult = this.persistNewEntity(callCtx, ms, updatedPrincipal);
@@ -1616,21 +1615,6 @@ public class AtomicOperationMetaStoreManager extends BaseMetaStoreManager {
}
}
- /**
- * Get the internal property map for an entity
- *
- * @param entity the target entity
- * @return a map of string representing the internal properties
- */
- public Map<String, String> getInternalPropertyMap(@Nonnull PolarisBaseEntity entity) {
- String internalPropStr = entity.getInternalProperties();
- Map<String, String> res = new HashMap<>();
- if (internalPropStr == null) {
- return res;
- }
- return deserializeProperties(internalPropStr);
- }
-
/** {@inheritDoc} */
@Override
public @Nonnull ResolvedEntityResult loadResolvedEntityById(
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
index a56eeda3d..6fb8448d1 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
@@ -18,9 +18,6 @@
*/
package org.apache.polaris.core.persistence;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Nonnull;
import java.util.Map;
import org.apache.polaris.core.PolarisCallContext;
@@ -34,8 +31,6 @@ import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
/** Shared basic PolarisMetaStoreManager logic for transactional and non-transactional impls. */
public abstract class BaseMetaStoreManager implements PolarisMetaStoreManager {
- /** mapper, allows to serialize/deserialize properties to/from JSON */
- private static final ObjectMapper MAPPER = new ObjectMapper();
public static PolarisStorageConfigurationInfo extractStorageConfiguration(
@Nonnull PolarisDiagnostics diagnostics, PolarisBaseEntity reloadedEntity) {
@@ -52,36 +47,6 @@ public abstract class BaseMetaStoreManager implements PolarisMetaStoreManager {
return PolarisStorageConfigurationInfo.deserialize(storageConfigInfoStr);
}
- /**
- * Given the internal property as a map of key/value pairs, serialize it to a String
- *
- * @param properties a map of key/value pairs
- * @return a String, the JSON representation of the map
- */
- public String serializeProperties(Map<String, String> properties) {
- try {
- // Deserialize the JSON string to a Map<String, String>
- return MAPPER.writeValueAsString(properties);
- } catch (JsonProcessingException ex) {
- throw new RuntimeException("serializeProperties failed: " + ex.getMessage(), ex);
- }
- }
-
- /**
- * Given the serialized properties, deserialize those to a {@code Map<String, String>}
- *
- * @param properties a JSON string representing the set of properties
- * @return a Map of string
- */
- public Map<String, String> deserializeProperties(String properties) {
- try {
- // Deserialize the JSON string to a Map<String, String>
- return MAPPER.readValue(properties, new TypeReference<>() {});
- } catch (JsonProcessingException ex) {
- throw new RuntimeException("deserializeProperties failed: " + ex.getMessage(), ex);
- }
- }
-
/**
* Performs basic validation of expected invariants on a new entity, then returns the entity with
* fields filled out for which the persistence layer is responsible.
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
index 7e1a4ce45..ee202d3ca 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
@@ -240,7 +240,7 @@ public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
// if it is a principal, we also need to drop the secrets
if (entity.getType() == PolarisEntityType.PRINCIPAL) {
// get internal properties
- Map<String, String> properties = this.deserializeProperties(entity.getInternalProperties());
+ Map<String, String> properties = entity.getInternalPropertiesAsMap();
// get client_id
String clientId = properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -743,8 +743,7 @@ public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
principal);
// get internal properties
- Map<String, String> properties =
- this.deserializeProperties(refreshPrincipal.getInternalProperties());
+ Map<String, String> properties = refreshPrincipal.getInternalPropertiesAsMap();
// get client_id
String clientId = properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -792,14 +791,14 @@ public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
ms.generateNewPrincipalSecretsInCurrentTxn(callCtx, principal.getName(), principal.getId());
// generate properties
- Map<String, String> internalProperties = getInternalPropertyMap(principal);
+ Map<String, String> internalProperties = principal.getInternalPropertiesAsMap();
internalProperties.put(
PolarisEntityConstants.getClientIdPropertyName(), principalSecrets.getPrincipalClientId());
// remember client id
PolarisBaseEntity updatedPrincipal =
new PolarisBaseEntity.Builder(principal)
- .internalProperties(this.serializeProperties(internalProperties))
+ .internalPropertiesAsMap(internalProperties)
.build();
// now create and persist new catalog entity
@@ -926,7 +925,7 @@ public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
// get metastore we should be using
TransactionalPersistence ms = ((TransactionalPersistence) callCtx.getMetaStore());
- Map<String, String> internalProp = getInternalPropertyMap(catalog);
+ Map<String, String> internalProp = catalog.getInternalPropertiesAsMap();
String integrationIdentifierOrId =
internalProp.get(PolarisEntityConstants.getStorageIntegrationIdentifierPropertyName());
String storageConfigInfoStr =
@@ -2017,21 +2016,6 @@ public class TransactionalMetaStoreManagerImpl extends BaseMetaStoreManager {
}
}
- /**
- * Get the internal property map for an entity
- *
- * @param entity the target entity
- * @return a map of string representing the internal properties
- */
- public Map<String, String> getInternalPropertyMap(@Nonnull PolarisBaseEntity entity) {
- String internalPropStr = entity.getInternalProperties();
- Map<String, String> res = new HashMap<>();
- if (internalPropStr == null) {
- return res;
- }
- return deserializeProperties(internalPropStr);
- }
-
/** {@link #loadResolvedEntityById(PolarisCallContext, long, long, PolarisEntityType)} */
private @Nonnull ResolvedEntityResult loadResolvedEntityById(
@Nonnull PolarisCallContext callCtx,