-
Notifications
You must be signed in to change notification settings - Fork 836
[#11103] feat(core): Add the hierarchy convention layer #11074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2b11f1f
61dcc02
5e175bb
cb21732
caf3b96
d87ba6a
4ff4163
3c4f7db
6d23138
cbbdb8a
6fa7da4
42d4809
3d3f4dd
993e482
ae98cf3
7cfe982
26319b7
dbcf096
29cb2ac
7b0c466
74a0a7d
e9134fd
8cf90f7
bac3a3c
060815a
b2c78e5
f8690dc
16d9a56
df927bb
a960062
3d652c8
e72918b
6148465
f31fe4a
60a12ec
617ba19
525f2c6
722859c
9809cb6
09be3a6
4e40b48
9be45fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ | |
| /** | ||
| * Relation store to store entities. This means we can store entities in a relational store. I.e., | ||
| * MySQL, PostgreSQL, etc. If you want to use a different backend, you can implement the {@link | ||
| * RelationalBackend} interface | ||
| * RelationalBackend} interface. The default JDBC backend is {@link JDBCBackend}. | ||
| */ | ||
| public class RelationalEntityStore implements EntityStore, SupportsRelationOperations { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(RelationalEntityStore.class); | ||
|
|
@@ -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); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to add this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will set owners for multiple metadata objects. So I need to insert multiple relations. Although we already have the update multiple relations, it can't cover the cases when we need to insert multiple records. |
||
|
|
||
| @Override | ||
| public <E extends Entity & HasIdentifier> List<E> updateEntityRelations( | ||
| Type relType, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> entityIds) { | ||
| throw new UnsupportedOperationException( | ||
| "listPOs by entityIds is not supported by " + getClass().getSimpleName()); | ||
| } | ||
|
|
||
| public PO getPOByFullName(Mapper mapper, NameIdentifier identifier) { | ||
| throw new UnsupportedOperationException( | ||
| "getPOByFullName is not supported by " + getClass().getSimpleName()); | ||
| } | ||
|
|
||
| public List<PO> listPOsByNSFullName(Mapper mapper, Namespace namespace) { | ||
| throw new UnsupportedOperationException( | ||
| "listPOsByNSFullName is not supported by " + getClass().getSimpleName()); | ||
| } | ||
|
|
||
| protected abstract Entity.EntityType entityType(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it more proper to invalidate the cache first and then operate the database?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take a look. Other relation ops follows this pattern, too. Do we need to modify them together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diqiu50
Please take a look, and I recall that you have modified this point.