ATLAS-5194: Add pagination while fetching relationships of an entity#510
Merged
pinal-shah merged 1 commit intoapache:masterfrom Mar 13, 2026
Merged
ATLAS-5194: Add pagination while fetching relationships of an entity#510pinal-shah merged 1 commit intoapache:masterfrom
pinal-shah merged 1 commit intoapache:masterfrom
Conversation
mandarambawane
approved these changes
Feb 2, 2026
pinal-shah
requested changes
Feb 4, 2026
| * @throws AtlasBaseException | ||
| */ | ||
| @GET | ||
| @Path("relationship/v2") |
Collaborator
There was a problem hiding this comment.
Please review if there is need to introduce new API
| */ | ||
| @GraphTransaction | ||
| @Override | ||
| public AtlasSearchResult searchRelatedEntitiesV2(String guid, String relation, boolean getApproximateCount, SearchParameters searchParameters, boolean disableDefaultSorting) throws AtlasBaseException { |
Collaborator
There was a problem hiding this comment.
Please incorporate changes in the existing method, to avoid code duplication
fbb2299 to
8c111f4
Compare
pinal-shah
reviewed
Mar 12, 2026
45eca01 to
3092442
Compare
pinal-shah
approved these changes
Mar 12, 2026
3092442 to
473139e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Added a new
disableDefaultSortingboolean parameter to thesearchRelatedEntitiesAPI across the REST layer, service interface, and implementation. Whenfalse(default), the API maintains backward compatibility by applying default "name" sorting if no explicitsortByis provided. Whentrue, no default sorting is applied, returning results in natural graph traversal order.Fixed a critical bug in approximate count calculation where deleted entities were incorrectly included in the count when
excludeDeletedEntities=true- the implementation now correctly filters by end vertex status instead of edge status.Updated all existing tests to use
disableDefaultSorting=falseto preserve current behaviour, and added new test cases to verify sorting logic and accurate count calculation.Why It Was Needed?
The existing
searchRelatedEntitiesAPI always applied default "name" sorting even when users didn't specify asortByparameter, which could impact performance for large datasets where users don't need sorted results. This forced sorting behaviour couldn't be disabled, making deep pagination slower than necessary. The new parameter gives users the flexibility to opt out of default sorting when they prioritise performance over order, particularly useful for paginated queries on entities with thousands of relationships.How was this patch tested?
DiscoveryRESTTest,EntityDiscoveryServiceTest, andAtlasDiscoveryServiceTestto passdisableDefaultSorting=false,ensuring backward compatibilitytestSearchRelatedEntitiesWithDisableDefaultSorting()to verify both sorted (disableDefaultSorting=false) and unsorted (disableDefaultSorting=true) paths return the same entitiestestSearchRelatedEntitiesWithOffset()to verify correct pagination behaviour across multiple pagestestSearchRelatedEntitiesWithDeletedEntities) and approximate count accuracy (testApproximateCountExcludesDeleted) with the new parameter