sheetalshah1007 commented on code in PR #304:
URL: https://github.com/apache/atlas/pull/304#discussion_r1991344451


##########
repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java:
##########
@@ -119,30 +121,62 @@ public static boolean isNameInvalid(String name) {
      */
     @GraphTransaction
     public List<AtlasGlossary> getGlossaries(int limit, int offset, SortOrder 
sortOrder) throws AtlasBaseException {
-        LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, 
offset, sortOrder);
+        if (DEBUG_ENABLED) {
+            LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, 
offset, sortOrder);
+        }
+
+        List<String> glossaryGuids = 
AtlasGraphUtilsV2.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, 
sortOrder);
+
+        if (CollectionUtils.isEmpty(glossaryGuids)) {
+            return Collections.emptyList();
+        }
 
-        List<String>             glossaryGuids    = 
AtlasGraphUtilsV2.findEntityGUIDsByType(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME, 
sortOrder);
-        PaginationHelper<String> paginationHelper = new 
PaginationHelper<>(glossaryGuids, offset, limit);
+        List<AtlasGlossary> ret = new ArrayList<>();
+        int currentOffset = offset;
+        int maxSize = glossaryGuids.size();
 
-        List<AtlasGlossary>                  ret;
-        List<String>                         guidsToLoad = 
paginationHelper.getPaginatedList();
-        AtlasEntity.AtlasEntitiesWithExtInfo glossaryEntities;
+        // If limit is negative, use maxSize; otherwise, take the minimum of 
limit and maxSize
+        int adjustedLimit = (limit < 0) ? maxSize : Integer.min(maxSize, 
limit);
 
-        if (CollectionUtils.isNotEmpty(guidsToLoad)) {
-            glossaryEntities = 
dataAccess.getAtlasEntityStore().getByIds(guidsToLoad, true, false);
-            ret              = new ArrayList<>();
+        // Enable skipping failed entities during processing
+        RequestContext.get().setSkipFailedEntities(true);
 
-            for (AtlasEntity glossaryEntity : glossaryEntities.getEntities()) {
-                AtlasGlossary glossary = glossaryDTO.from(glossaryEntity);
+        while (ret.size() < adjustedLimit && currentOffset < 
glossaryGuids.size()) {
+            // Fetch next batch of GUIDs
+            PaginationHelper<String> paginationHelper = new 
PaginationHelper<>(glossaryGuids, currentOffset, adjustedLimit - ret.size());

Review Comment:
   yes, recent patches include this 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: dev-unsubscr...@atlas.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to