Skip to content

Commit 7749733

Browse files
ATLAS-5147: Relationship Search API approximateCount returns pageLimit value instead of total relationship count#2
1 parent 84e8c7f commit 7749733

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusIndexQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public Iterator<Result<AtlasJanusVertex, AtlasJanusEdge>> edges(int offset, int
114114

115115
@Override
116116
public Long edgeTotals() {
117-
return query.edgeTotals();
117+
return query.offset(0).limit(Integer.MAX_VALUE).edgeTotals();
118118
}
119119

120120
/**

repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.slf4j.LoggerFactory;
4141
import org.testng.annotations.AfterClass;
4242
import org.testng.annotations.BeforeClass;
43+
import org.testng.annotations.DataProvider;
4344
import org.testng.annotations.Guice;
4445
import org.testng.annotations.Test;
4546

@@ -836,4 +837,21 @@ private void createChineseEntityWithDescription() throws AtlasBaseException {
836837

837838
cjkGuid2 = entityHeader.getGuid();
838839
}
840+
841+
@DataProvider(name = "limitProvider")
842+
public Integer[] limitProvider() {
843+
return new Integer[] {15, 0, 1, 10, 20};
844+
}
845+
846+
@Test(dependsOnMethods = "searchWithNEQ_stringAttr", dataProvider = "limitProvider")
847+
public void testEntitySearchApproxCountForAllLimits(int limit) throws AtlasBaseException {
848+
SearchParameters params = new SearchParameters();
849+
params.setTypeName(HIVE_TABLE_TYPE);
850+
params.setLimit(limit);
851+
852+
SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.emptySet());
853+
EntitySearchProcessor processor = new EntitySearchProcessor(context);
854+
855+
assertEquals(processor.getResultCount(), 11);
856+
}
839857
}

repository/src/test/java/org/apache/atlas/discovery/RelationshipSearchProcessorTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.commons.collections.CollectionUtils;
3030
import org.testng.annotations.AfterClass;
3131
import org.testng.annotations.BeforeClass;
32+
import org.testng.annotations.DataProvider;
3233
import org.testng.annotations.Guice;
3334
import org.testng.annotations.Test;
3435

@@ -65,6 +66,23 @@ public void totalRelationships() throws AtlasBaseException {
6566
executeAndAssert(params, 17);
6667
}
6768

69+
@DataProvider(name = "limitProvider")
70+
public Integer[] limitProvider() {
71+
return new Integer[] {15, 0, 1, 17, 20};
72+
}
73+
74+
@Test(dataProvider = "limitProvider")
75+
public void testRelationshipsApproxCountForAllLimits(int limit) throws AtlasBaseException {
76+
SearchParameters params = new SearchParameters();
77+
params.setRelationshipName(USER_POST_TYPE);
78+
params.setLimit(limit);
79+
80+
SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.emptySet());
81+
RelationshipSearchProcessor processor = new RelationshipSearchProcessor(context, indexer.getEdgeIndexKeys());
82+
83+
assertEquals(processor.getResultCount(), 17);
84+
}
85+
6886
@Test
6987
public void searchByAttribute() throws AtlasBaseException {
7088
SearchParameters params = new SearchParameters();

0 commit comments

Comments
 (0)