jerqi commented on code in PR #6601:
URL: https://github.com/apache/gravitino/pull/6601#discussion_r1987150285
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/MetadataObjectService.java:
##########
@@ -214,4 +233,407 @@ public static String getMetadataObjectFullName(String
type, long metadataObjectI
return fullName;
}
+
+ /**
+ * Retrieves a map of Metalake object IDs to their full names.
+ *
+ * @param ids A list of Metalake object IDs to fetch names for.
+ * @return A Map where the key is the Metalake ID and the value is the
Metalake full name. The map
+ * may contain null values for the names if its parent object is
deleted. Returns an empty map
+ * if no Metalake objects are found for the given IDs. {@code @example}
value of metalake full
+ * name: "metalake1.catalog1.schema1.table1"
+ */
+ public static Map<Long, String> getMetalakeObjectsFullName(List<Long> ids) {
+ List<MetalakePO> metalakePOs =
+ SessionUtils.getWithoutCommit(
+ MetalakeMetaMapper.class, mapper ->
mapper.listMetalakePOsByMetalakeIds(ids));
+
+ if (metalakePOs == null || metalakePOs.isEmpty()) {
+ return new HashMap<>();
+ }
+
+ HashMap<Long, String> metalakeIdAndNameMap = new HashMap<>();
+
+ metalakePOs.forEach(
+ metalakePO -> {
+ if (metalakePO.getMetalakeId() == null) {
+ metalakeIdAndNameMap.put(metalakePO.getMetalakeId(), null);
+ return;
+ }
+ metalakeIdAndNameMap.put(metalakePO.getMetalakeId(),
metalakePO.getMetalakeName());
+ });
+
+ return metalakeIdAndNameMap;
+ }
+
+ /**
+ * Retrieves a map of Fileset object IDs to their full names.
+ *
+ * @param ids A list of Fileset object IDs to fetch names for.
+ * @return A Map where the key is the Fileset ID and the value is the
Fileset full name. The map
+ * may contain null values for the names if its parent object is
deleted. Returns an empty map
+ * if no Fileset objects are found for the given IDs. {@code @example}
value of fileset full
+ * name: "catalog1.schema1.fileset1"
+ */
+ public static Map<Long, String> getFilesetObjectsFullName(List<Long> ids) {
+ List<FilesetPO> filesetPOs =
+ SessionUtils.getWithoutCommit(
+ FilesetMetaMapper.class, mapper ->
mapper.listFilesetPOsByFilesetIds(ids));
+
+ if (filesetPOs == null || filesetPOs.isEmpty()) {
+ return new HashMap<>();
+ }
+
+ List<Long> catalogIds =
+
filesetPOs.stream().map(FilesetPO::getCatalogId).collect(Collectors.toList());
+ List<Long> schemaIds =
+
filesetPOs.stream().map(FilesetPO::getSchemaId).collect(Collectors.toList());
+
+ Map<Long, String> catalogIdAndNameMap = getCatalogIdAndNameMap(catalogIds);
+ Map<Long, String> schemaIdAndNameMap = getSchemaIdAndNameMap(schemaIds);
Review Comment:
Maybe you can use getSchemaObjectsFullName here.
--
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]