Skip to content

Commit 8828701

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

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-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/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};
72+
}
73+
74+
@Test(dataProvider = "limitProvider")
75+
public void testRelationshipsApproxCount_WithVariousLimits(int limit) throws AtlasBaseException {
76+
SearchParameters params = new SearchParameters();
77+
params.setRelationshipName("user_post");
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)