yuqi1129 commented on code in PR #9430:
URL: https://github.com/apache/gravitino/pull/9430#discussion_r2667609870
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/FilesetMetaService.java:
##########
@@ -347,6 +354,56 @@ public int deleteFilesetVersionsByRetentionCount(Long
versionRetentionCount, int
return totalDeletedCount;
}
+ private FilesetPO getFilesetPOByIdentifier(NameIdentifier identifier) {
+ NameIdentifierUtil.checkFileset(identifier);
+
+ return filesetPOFetcher().apply(identifier);
+ }
+
+ private FilesetPO getFilesetPOBySchemaId(NameIdentifier identifier) {
+ Long schemaId =
+ EntityIdService.getEntityId(
+ NameIdentifier.of(identifier.namespace().levels()),
Entity.EntityType.SCHEMA);
+ return getFilesetPOBySchemaIdAndName(schemaId, identifier.name());
+ }
+
+ private FilesetPO getFilesetPOByFullQualifiedName(NameIdentifier identifier)
{
+ String[] namespaceLevels = identifier.namespace().levels();
+ FilesetPO filesetPO =
+ getFilesetByFullQualifiedName(
+ namespaceLevels[0], namespaceLevels[1], namespaceLevels[2],
identifier.name());
+
+ if (filesetPO.getSchemaId() == null) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.SCHEMA.name().toLowerCase(),
+ namespaceLevels[2]);
+ }
+
+ if (filesetPO.getFilesetId() == null) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.FILESET.name().toLowerCase(),
+ identifier.name());
+ }
+
+ return filesetPO;
+ }
+
+ private Function<Namespace, List<FilesetPO>> filesetListFetcher() {
+ return cacheEnabled()
+ ? this::listFilesetPOsBySchemaId
+ : this::listFilesetPOsByFullQualifiedName;
+ }
+
+ private Function<NameIdentifier, FilesetPO> filesetPOFetcher() {
+ return cacheEnabled() ? this::getFilesetPOBySchemaId :
this::getFilesetPOByFullQualifiedName;
+ }
+
+ private boolean cacheEnabled() {
+ return GravitinoEnv.getInstance().config().get(Configs.CACHE_ENABLED);
+ }
Review Comment:
@mchades
As you two addressed, we need to reach agreement about whether we keep two
code path before I make the change.
--
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]