collado-mike commented on code in PR #2508:
URL: https://github.com/apache/polaris/pull/2508#discussion_r2373675580


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java:
##########
@@ -1531,14 +1532,42 @@ private void revokeGrantRecord(
         : new EntityResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, null);
   }
 
+  @Nonnull
+  @Override
+  public EntitiesResult loadEntities(
+      @Nonnull PolarisCallContext callCtx,
+      @Nonnull List<EntityNameLookupRecord> entityLookupRecords) {
+    BasePersistence ms = callCtx.getMetaStore();
+    List<PolarisBaseEntity> entities =
+        ms.lookupEntities(
+            callCtx,
+            entityLookupRecords.stream()
+                .map(r -> new PolarisEntityId(r.getCatalogId(), r.getId()))
+                .collect(Collectors.toList()));
+    // mimic the behavior of loadEntity above, return null if not found or 
type mismatch
+    List<PolarisBaseEntity> ret =
+        IntStream.range(0, entityLookupRecords.size())
+            .mapToObj(
+                i -> {
+                  if (entities.get(i) != null
+                      && 
!entities.get(i).getType().equals(entityLookupRecords.get(i).getType())) {
+                    return null;
+                  } else {
+                    return entities.get(i);

Review Comment:
   When I was deduping this code to support both load by id and by lookup 
record, I ended up keeping the access by index so I could use a function to get 
the type of the entity. I generally think it's reasonable to expect access by 
index for List implementations in practical use



-- 
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]

Reply via email to