dimas-b commented on code in PR #1070:
URL: https://github.com/apache/polaris/pull/1070#discussion_r1972543530


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.entity.PolarisBaseEntity;
+import org.apache.polaris.core.entity.PolarisChangeTrackingVersions;
+import org.apache.polaris.core.entity.PolarisEntityActiveRecord;
+import org.apache.polaris.core.entity.PolarisEntityCore;
+import org.apache.polaris.core.entity.PolarisEntityId;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.entity.PolarisGrantRecord;
+import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+
+/**
+ * Interface to the Polaris metadata store, allows to persist and retrieve all 
Polaris metadata like
+ * metadata for Polaris entities and metadata about grants between these 
entities which is the
+ * foundation of our role base access control model.
+ *
+ * <p>Note that APIs to the actual persistence store are very basic, often 
point read or write to
+ * the underlying data store. The goal is to make it really easy to back this 
using databases like
+ * Postgres or simpler KV store.
+ */
+public interface BasePersistence {

Review Comment:
   why "Base"?



##########
service/common/src/main/java/org/apache/polaris/service/context/DefaultCallContextResolver.java:
##########
@@ -60,6 +60,10 @@ public CallContext resolveCallContext(
         .addKeyValue("headers", headers)
         .log("Resolving CallContext");
 
+    // TODO: Once we have non-transactional-database persistence stores, this 
should be
+    // pushed down for the metaStoreManagerFactory to inject Transactional-DB 
specific things
+    // (including the MetaStoreSession" into the PolarisCallContext. The 
non-transactional

Review Comment:
   Why would `PolarisCallContext` have DB-specific stuff? How do you envision 
the purpose and use cases of `PolarisCallContext`?



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.entity.PolarisBaseEntity;
+import org.apache.polaris.core.entity.PolarisChangeTrackingVersions;
+import org.apache.polaris.core.entity.PolarisEntityActiveRecord;
+import org.apache.polaris.core.entity.PolarisEntityCore;
+import org.apache.polaris.core.entity.PolarisEntityId;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.entity.PolarisGrantRecord;
+import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+
+/**
+ * Interface to the Polaris metadata store, allows to persist and retrieve all 
Polaris metadata like
+ * metadata for Polaris entities and metadata about grants between these 
entities which is the
+ * foundation of our role base access control model.
+ *
+ * <p>Note that APIs to the actual persistence store are very basic, often 
point read or write to
+ * the underlying data store. The goal is to make it really easy to back this 
using databases like
+ * Postgres or simpler KV store.
+ */
+public interface BasePersistence {
+  /**
+   * @param callCtx call context
+   * @return new unique entity identifier
+   */
+  long generateNewId(@Nonnull PolarisCallContext callCtx);
+
+  /**
+   * Write this entity to the meta store.
+   *
+   * @param callCtx call context
+   * @param entity entity to persist
+   * @param nameOrParentChanged if true, also write it to by-name lookups if 
applicable
+   * @param originalEntity original state of the entity to use for 
compare-and-swap purposes, or

Review Comment:
   I believe we need to have explicit statements about concurrent update 
expectations (e.g. exception on conflict) and durability expectation (i.e. 
successful return means that the change was persisted).



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.entity.PolarisBaseEntity;
+import org.apache.polaris.core.entity.PolarisChangeTrackingVersions;
+import org.apache.polaris.core.entity.PolarisEntityActiveRecord;
+import org.apache.polaris.core.entity.PolarisEntityCore;
+import org.apache.polaris.core.entity.PolarisEntityId;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.entity.PolarisGrantRecord;
+import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+
+/**
+ * Interface to the Polaris metadata store, allows to persist and retrieve all 
Polaris metadata like
+ * metadata for Polaris entities and metadata about grants between these 
entities which is the
+ * foundation of our role base access control model.
+ *
+ * <p>Note that APIs to the actual persistence store are very basic, often 
point read or write to
+ * the underlying data store. The goal is to make it really easy to back this 
using databases like
+ * Postgres or simpler KV store.
+ */
+public interface BasePersistence {
+  /**
+   * @param callCtx call context
+   * @return new unique entity identifier
+   */
+  long generateNewId(@Nonnull PolarisCallContext callCtx);

Review Comment:
   Please specify ID uniqueness expectations.
   
   Also, is ID generation permanent on return from this method (i.e. 
"committed" in RDBMS terms)?



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.entity.PolarisBaseEntity;
+import org.apache.polaris.core.entity.PolarisChangeTrackingVersions;
+import org.apache.polaris.core.entity.PolarisEntityActiveRecord;
+import org.apache.polaris.core.entity.PolarisEntityCore;
+import org.apache.polaris.core.entity.PolarisEntityId;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.entity.PolarisGrantRecord;
+import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+
+/**
+ * Interface to the Polaris metadata store, allows to persist and retrieve all 
Polaris metadata like
+ * metadata for Polaris entities and metadata about grants between these 
entities which is the
+ * foundation of our role base access control model.
+ *
+ * <p>Note that APIs to the actual persistence store are very basic, often 
point read or write to
+ * the underlying data store. The goal is to make it really easy to back this 
using databases like
+ * Postgres or simpler KV store.
+ */
+public interface BasePersistence {
+  /**
+   * @param callCtx call context
+   * @return new unique entity identifier
+   */
+  long generateNewId(@Nonnull PolarisCallContext callCtx);
+
+  /**
+   * Write this entity to the meta store.
+   *
+   * @param callCtx call context
+   * @param entity entity to persist
+   * @param nameOrParentChanged if true, also write it to by-name lookups if 
applicable
+   * @param originalEntity original state of the entity to use for 
compare-and-swap purposes, or
+   *     null if this is expected to be a brand-new entity
+   */
+  void writeEntity(
+      @Nonnull PolarisCallContext callCtx,

Review Comment:
   I'm generally against "call contexts" as explicit method parameters (or 
thread locals) from the API design POV.
   
   Is there a reason why call context objects cannot be injected into impl. 
classes (Request-scoped beans in CDI)?



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/BasePersistence.java:
##########
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.persistence;
+
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import org.apache.polaris.core.PolarisCallContext;
+import org.apache.polaris.core.entity.PolarisBaseEntity;
+import org.apache.polaris.core.entity.PolarisChangeTrackingVersions;
+import org.apache.polaris.core.entity.PolarisEntityActiveRecord;
+import org.apache.polaris.core.entity.PolarisEntityCore;
+import org.apache.polaris.core.entity.PolarisEntityId;
+import org.apache.polaris.core.entity.PolarisEntityType;
+import org.apache.polaris.core.entity.PolarisGrantRecord;
+import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+
+/**
+ * Interface to the Polaris metadata store, allows to persist and retrieve all 
Polaris metadata like
+ * metadata for Polaris entities and metadata about grants between these 
entities which is the
+ * foundation of our role base access control model.
+ *
+ * <p>Note that APIs to the actual persistence store are very basic, often 
point read or write to
+ * the underlying data store. The goal is to make it really easy to back this 
using databases like
+ * Postgres or simpler KV store.
+ */
+public interface BasePersistence {
+  /**
+   * @param callCtx call context
+   * @return new unique entity identifier
+   */
+  long generateNewId(@Nonnull PolarisCallContext callCtx);
+
+  /**
+   * Write this entity to the meta store.
+   *
+   * @param callCtx call context
+   * @param entity entity to persist
+   * @param nameOrParentChanged if true, also write it to by-name lookups if 
applicable
+   * @param originalEntity original state of the entity to use for 
compare-and-swap purposes, or
+   *     null if this is expected to be a brand-new entity
+   */
+  void writeEntity(
+      @Nonnull PolarisCallContext callCtx,
+      @Nonnull PolarisBaseEntity entity,
+      boolean nameOrParentChanged,
+      @Nullable PolarisBaseEntity originalEntity);
+
+  /**
+   * Write the specified grantRecord to the grant_records table. If there is a 
conflict (existing
+   * record with the same PK), all attributes of the new record will replace 
the existing one.
+   *
+   * @param callCtx call context
+   * @param grantRec entity record to write, potentially replacing an existing 
entity record with
+   *     the same key
+   */
+  void writeToGrantRecords(

Review Comment:
   It looks like grant records a different from "entities", right? If so, why 
not have a separate persistence interface for them?



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