lasdf1234 commented on code in PR #12006:
URL: https://github.com/apache/gravitino/pull/12006#discussion_r3671859215
##########
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java:
##########
@@ -396,37 +339,12 @@ public <E extends Entity & HasIdentifier> E
getEntityByRelation(
Entity.EntityType srcType,
NameIdentifier destEntityIdent)
throws IOException, NoSuchEntityException {
- return cache.withCacheLock(
- EntityCacheRelationKey.of(srcIdentifier, srcType, relType),
- () -> {
- Optional<List<E>> entities = cache.getIfPresent(relType,
srcIdentifier, srcType);
- if (entities.isPresent()) {
- return entities.get().stream()
- .filter(e -> e.nameIdentifier().equals(destEntityIdent))
- .findFirst()
- .orElseThrow(
- () ->
- new NoSuchEntityException(
- "No such entity with ident: %s", destEntityIdent));
- }
-
- // Use allFields=true to cache complete entities
- List<E> backendEntities =
- backend.listEntitiesByRelation(relType, srcIdentifier, srcType,
true);
-
- E r =
- backendEntities.stream()
- .filter(e -> e.nameIdentifier().equals(destEntityIdent))
- .findFirst()
- .orElseThrow(
- () ->
- new NoSuchEntityException(
- "No such entity with ident: %s",
destEntityIdent));
-
- cache.put(srcIdentifier, srcType, relType, backendEntities);
-
- return r;
- });
+ List<E> backendEntities = backend.listEntitiesByRelation(relType,
srcIdentifier, srcType, true);
+ return backendEntities.stream()
+ .filter(e -> e.nameIdentifier().equals(destEntityIdent))
+ .findFirst()
+ .orElseThrow(
+ () -> new NoSuchEntityException("No such entity with ident: %s",
destEntityIdent));
}
Review Comment:
Could we remove return backendEntities.stream()
.filter(e -> e.nameIdentifier().equals(destEntityIdent))
.findFirst()
.orElseThrow(
() -> new NoSuchEntityException("No such entity with ident: %s",
destEntityIdent)); ?
Directly call the method of the backend?
--
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]