XN137 commented on code in PR #2290: URL: https://github.com/apache/polaris/pull/2290#discussion_r2265983466
########## runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalog.java: ########## @@ -162,34 +161,15 @@ public List<PolicyIdentifier> listPolicies(Namespace namespace, PolicyType polic } List<PolarisEntity> catalogPath = resolvedEntities.getRawFullPath(); - List<PolicyEntity> policyEntities = - metaStoreManager - .listEntities( - callContext.getPolarisCallContext(), - PolarisEntity.toCoreList(catalogPath), - PolarisEntityType.POLICY, - PolarisEntitySubType.NULL_SUBTYPE, - PageToken.readEverything()) - .getEntities() - .stream() - .map( - polarisEntityActiveRecord -> - PolicyEntity.of( - metaStoreManager - .loadEntity( - callContext.getPolarisCallContext(), - polarisEntityActiveRecord.getCatalogId(), - polarisEntityActiveRecord.getId(), - polarisEntityActiveRecord.getType()) - .getEntity())) - .filter( - policyEntity -> policyType == null || policyEntity.getPolicyType() == policyType) - .toList(); - - List<PolarisEntity.NameAndId> entities = - policyEntities.stream().map(PolarisEntity::nameAndId).toList(); - - return entities.stream() + return metaStoreManager + .loadEntitiesAll( + callContext.getPolarisCallContext(), + PolarisEntity.toCoreList(catalogPath), + PolarisEntityType.POLICY, + PolarisEntitySubType.NULL_SUBTYPE, + PolicyEntity::of) + .stream() + .filter(policyEntity -> policyType == null || policyEntity.getPolicyType() == policyType) Review Comment: side note: if the required `policyType` is `null` we could in theory use the optimized `listEntities` call, as we only need the name of the entity to build the `PolicyIdentifier`, but for filtering by `policyType` we need to load the full entity. -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org