This is an automated email from the ASF dual-hosted git repository.

pinal pushed a commit to branch atlas-2.5
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/atlas-2.5 by this push:
     new bd1681a42 ATLAS-5147: Relationship Search API approximateCount returns 
pageLimit value instead of total relationship count#2 (#477)
bd1681a42 is described below

commit bd1681a4295ba1313ab755ffa67d74e059a05dec
Author: Aditya Gupta <[email protected]>
AuthorDate: Thu Feb 5 14:44:57 2026 +0530

    ATLAS-5147: Relationship Search API approximateCount returns pageLimit 
value instead of total relationship count#2 (#477)
    
    (cherry picked from commit afd12f0fb9367b8f7bde40683a99d8f0f5996df3)
---
 .../repository/graphdb/janus/AtlasJanusIndexQuery.java |  2 +-
 .../atlas/discovery/EntitySearchProcessorTest.java     | 18 ++++++++++++++++++
 .../discovery/RelationshipSearchProcessorTest.java     | 18 ++++++++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusIndexQuery.java
 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusIndexQuery.java
index f1f6b18ac..3265ffc32 100644
--- 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusIndexQuery.java
+++ 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusIndexQuery.java
@@ -114,7 +114,7 @@ public class AtlasJanusIndexQuery implements 
AtlasIndexQuery<AtlasJanusVertex, A
 
     @Override
     public Long edgeTotals() {
-        return query.edgeTotals();
+        return query.offset(0).limit(Integer.MAX_VALUE).edgeTotals();
     }
 
     /**
diff --git 
a/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java
 
b/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java
index 85de35d53..2214a8340 100644
--- 
a/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java
+++ 
b/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
@@ -834,4 +835,21 @@ public class EntitySearchProcessorTest extends 
BasicTestSetup {
 
         cjkGuid2 = entityHeader.getGuid();
     }
+
+    @DataProvider(name = "limitProvider")
+    public Integer[] limitProvider() {
+        return new Integer[] {15, 0, 1, 10, 20};
+    }
+
+    @Test(dependsOnMethods = "searchWithNEQ_stringAttr", dataProvider = 
"limitProvider")
+    public void testEntitySearchApproxCountForAllLimits(int limit) throws 
AtlasBaseException {
+        SearchParameters params = new SearchParameters();
+        params.setTypeName(HIVE_TABLE_TYPE);
+        params.setLimit(limit);
+
+        SearchContext context = new SearchContext(params, typeRegistry, graph, 
Collections.emptySet());
+        EntitySearchProcessor processor = new EntitySearchProcessor(context);
+
+        assertEquals(processor.getResultCount(), 11);
+    }
 }
diff --git 
a/repository/src/test/java/org/apache/atlas/discovery/RelationshipSearchProcessorTest.java
 
b/repository/src/test/java/org/apache/atlas/discovery/RelationshipSearchProcessorTest.java
index 15c6c65bd..a8502b227 100644
--- 
a/repository/src/test/java/org/apache/atlas/discovery/RelationshipSearchProcessorTest.java
+++ 
b/repository/src/test/java/org/apache/atlas/discovery/RelationshipSearchProcessorTest.java
@@ -29,6 +29,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.commons.collections.CollectionUtils;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Guice;
 import org.testng.annotations.Test;
 
@@ -65,6 +66,23 @@ public class RelationshipSearchProcessorTest extends 
BasicTestSetup {
         executeAndAssert(params, 17);
     }
 
+    @DataProvider(name = "limitProvider")
+    public Integer[] limitProvider() {
+        return new Integer[] {15, 0, 1, 17, 20};
+    }
+
+    @Test(dataProvider = "limitProvider")
+    public void testRelationshipsApproxCountForAllLimits(int limit) throws 
AtlasBaseException {
+        SearchParameters params = new SearchParameters();
+        params.setRelationshipName(USER_POST_TYPE);
+        params.setLimit(limit);
+
+        SearchContext context = new SearchContext(params, typeRegistry, graph, 
Collections.emptySet());
+        RelationshipSearchProcessor processor = new 
RelationshipSearchProcessor(context, indexer.getEdgeIndexKeys());
+
+        assertEquals(processor.getResultCount(), 17);
+    }
+
     @Test
     public void searchByAttribute() throws AtlasBaseException {
         SearchParameters params = new SearchParameters();

Reply via email to