flyingImer commented on code in PR #4397:
URL: https://github.com/apache/polaris/pull/4397#discussion_r3237771581


##########
persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManagerFactory.java:
##########
@@ -136,6 +138,12 @@ public BasePersistence getOrCreateSession(RealmContext 
realmContext) {
     return 
newPersistenceMetaStore(initializedRealmPersistence(realmContext.getRealmIdentifier()));
   }
 
+  @Override

Review Comment:
   Nit: stateless, so a `private static final` singleton avoids per-call 
allocation.



##########
persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManagerFactory.java:
##########
@@ -136,6 +138,12 @@ public BasePersistence getOrCreateSession(RealmContext 
realmContext) {
     return 
newPersistenceMetaStore(initializedRealmPersistence(realmContext.getRealmIdentifier()));
   }
 
+  @Override
+  public MetricsPersistence getOrCreateMetricsPersistence(RealmContext 
realmContext) {

Review Comment:
   Nit: stateless, so a `private static final` singleton avoids per-call 
allocation.



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/MetaStoreManagerFactory.java:
##########
@@ -34,6 +35,13 @@ public interface MetaStoreManagerFactory {
 
   BasePersistence getOrCreateSession(RealmContext realmContext);
 
+  /**
+   * Returns the per-realm {@link MetricsPersistence}. This SPI is decoupled 
from {@link
+   * BasePersistence} so backends that do not implement metrics persistence 
can simply return a
+   * no-op instance.
+   */
+  MetricsPersistence getOrCreateMetricsPersistence(RealmContext realmContext);

Review Comment:
   Consider giving this a default implementation:
   ```java
   default MetricsPersistence getOrCreateMetricsPersistence(RealmContext 
realmContext) {
     return new MetricsPersistence() {};
   }
   ```
   MetricsPersistence methods are all no-op by default, so the factory should 
be too. Backends that don't implement metrics won't need to touch their factory 
class. They get silent no-op for free, and the source-breaking surface shrinks.



-- 
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]

Reply via email to