yuqi1129 commented on code in PR #11074:
URL: https://github.com/apache/gravitino/pull/11074#discussion_r3248251392
##########
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java:
##########
@@ -327,6 +327,26 @@ public void insertRelation(
cache.invalidate(dstIdentifier, dstType, relType);
}
+ @Override
+ public void batchInsertRelations(
+ Type relType,
+ List<NameIdentifier> srcIdentifiers,
+ Entity.EntityType srcType,
+ NameIdentifier dstIdentifier,
+ Entity.EntityType dstType,
+ boolean override)
+ throws IOException {
+ if (srcIdentifiers == null || srcIdentifiers.isEmpty()) {
+ return;
+ }
+ backend.batchInsertRelations(
+ relType, srcIdentifiers, srcType, dstIdentifier, dstType, override);
+ for (NameIdentifier ident : srcIdentifiers) {
+ cache.invalidate(ident, srcType, relType);
+ }
+ cache.invalidate(dstIdentifier, dstType, relType);
Review Comment:
Is it more proper to invalidate the cache first and then operate the
database?
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/BasePOStorageOps.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+
+public abstract class BasePOStorageOps<PO, Mapper> {
+ public void insertPO(Mapper mapper, PO po, boolean overwrite) {
+ throw new UnsupportedOperationException(
+ "insertPO is not supported by " + getClass().getSimpleName());
+ }
+
+ public void batchInsertPOs(Mapper mapper, List<PO> pos, boolean overwrite) {
+ throw new UnsupportedOperationException(
+ "batchInsertPOs is not supported by " + getClass().getSimpleName());
+ }
+
+ public Integer updatePO(Mapper mapper, PO newPO, PO oldPO) {
+ throw new UnsupportedOperationException(
+ "updatePO is not supported by " + getClass().getSimpleName());
+ }
+
+ /**
+ * When {@code true} and the entity-id cache is enabled, callers may resolve
rows by parent entity
+ * id plus short name via {@link #getPO} and {@link #listPOs}; see {@link
POStorageReadRouting}.
+ */
+ public boolean supportsParentIdRelationalRead() {
+ return false;
+ }
+
+ public PO getPO(Mapper mapper, Long parentId, String name) {
+ throw new UnsupportedOperationException(
+ "getPO by parent id is not supported by " +
getClass().getSimpleName());
+ }
+
+ public List<PO> listPOs(Mapper mapper, Long parentId) {
+ throw new UnsupportedOperationException(
+ "listPOs by parent id is not supported by " +
getClass().getSimpleName());
+ }
+
+ public List<PO> listPOs(Mapper mapper, Namespace namespace, List<String>
names) {
+ throw new UnsupportedOperationException(
+ "listPOs by namespace and names is not supported by " +
getClass().getSimpleName());
+ }
+
+ public List<PO> listPOs(Mapper mapper, List<Long> uuids) {
Review Comment:
uuids ?
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaPOStorageOps.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.gravitino.storage.relational.service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.gravitino.Entity;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.exceptions.NoSuchEntityException;
+import org.apache.gravitino.storage.relational.mapper.SchemaMetaMapper;
+import org.apache.gravitino.storage.relational.po.SchemaPO;
+
+public class SchemaPOStorageOps extends BasePOStorageOps<SchemaPO,
SchemaMetaMapper> {
+
+ public SchemaPOStorageOps() {}
+
+ @Override
+ public void batchInsertPOs(SchemaMetaMapper mapper, List<SchemaPO>
schemaPOs, boolean overwrite) {
+ if (overwrite) {
+ mapper.batchInsertSchemaMetaOnDuplicateKeyUpdate(schemaPOs);
+ } else {
+ mapper.batchInsertSchemaMeta(schemaPOs);
+ }
+ }
+
+ @Override
+ public Integer updatePO(SchemaMetaMapper mapper, SchemaPO oldPO, SchemaPO
newPO) {
+ return mapper.updateSchemaMeta(oldPO, newPO);
+ }
+
+ @Override
+ public SchemaPO getPO(SchemaMetaMapper mapper, Long parentId, String name) {
+ return mapper.selectSchemaMetaByCatalogIdAndName(parentId, name);
+ }
+
+ @Override
+ public SchemaPO getPOByFullName(SchemaMetaMapper mapper, NameIdentifier
identifier) {
+ Namespace namespace = identifier.namespace();
Review Comment:
There will be performance degradation if you are using the full qualified
name when cache is enabled, we can utilize the entity ID to retrieve entities.
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/MetadataObjectService.java:
##########
@@ -96,6 +96,14 @@ public class MetadataObjectService {
MetadataObjectService::getJobTemplateObjectsFullName)
.build();
+ static final Map<MetadataObject.Type, BasePOStorageOps<?, ?>>
TYPE_TO_STORAGE_OPS_MAP =
+ ImmutableMap.<MetadataObject.Type, BasePOStorageOps<?, ?>>builder()
+ .put(MetadataObject.Type.SCHEMA, new SchemaPOStorageOps())
Review Comment:
What about other types?
--
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]