You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sh...@apache.org on 2016/07/28 10:34:16 UTC
incubator-atlas git commit: ATLAS-1006 Paginate full text search
results (shwethags) [Forced Update!]
Repository: incubator-atlas
Updated Branches:
refs/heads/master b036e8d0f -> 4bc3e738e (forced update)
ATLAS-1006 Paginate full text search results (shwethags)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/4bc3e738
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/4bc3e738
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/4bc3e738
Branch: refs/heads/master
Commit: 4bc3e738eb692cdf141263e92b9b9785ff99da5c
Parents: 9ab13a3
Author: Shwetha GS <ss...@hortonworks.com>
Authored: Thu Jul 28 12:01:15 2016 +0530
Committer: Shwetha GS <ss...@hortonworks.com>
Committed: Thu Jul 28 16:02:50 2016 +0530
----------------------------------------------------------------------
.../main/java/org/apache/atlas/AtlasClient.java | 1 -
release-log.txt | 1 +
.../graph/GraphBackedDiscoveryService.java | 8 ++++-
.../GraphBackedMetadataRepositoryTest.java | 17 +++++++++++
.../resources/MetadataDiscoveryResource.java | 1 -
.../MetadataDiscoveryJerseyResourceIT.java | 32 ++++++++++++++++++--
6 files changed, 54 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/client/src/main/java/org/apache/atlas/AtlasClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/atlas/AtlasClient.java b/client/src/main/java/org/apache/atlas/AtlasClient.java
index d92cabc..e284ab4 100755
--- a/client/src/main/java/org/apache/atlas/AtlasClient.java
+++ b/client/src/main/java/org/apache/atlas/AtlasClient.java
@@ -1101,7 +1101,6 @@ public class AtlasClient {
* @param query Query
* @param limit number of rows to be returned in the result, used for pagination. maxlimit > limit > 0. -1 maps to atlas.search.defaultlimit property value
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
- * NOTE: Pagination is not implemented currently for full text search, so limit and offset are not used
* @return result json object
* @throws AtlasServiceException
*/
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 47f8eb6..52fd857 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES:
+ATLAS-1006 Paginate full text search results (shwethags)
ATLAS-1046 UI: Search pagination refinements (Kalyanikashikar via sumasai)
ATLAS-1056 Differentiate between tag and term using attribute "taxonomy.namespace" (kevalbhat18 via sumasai)
ATLAS-1059 Change log level to debug for search APIs(sumasai)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
index 81558dd..351bd12 100755
--- a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
@@ -91,7 +91,13 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
titanGraph.indexQuery(Constants.FULLTEXT_INDEX, graphQuery).vertices().iterator();
JSONArray response = new JSONArray();
- while (results.hasNext()) {
+ int index = 0;
+ while (results.hasNext() && index < queryParams.offset()) {
+ results.next();
+ index++;
+ }
+
+ while (results.hasNext() && response.length() < queryParams.limit()) {
TitanIndexQuery.Result<Vertex> result = results.next();
Vertex vertex = result.getElement();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
index 0d02333..9bd3682 100755
--- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
@@ -546,6 +546,23 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertEquals(results.length(), 1);
row = (JSONObject) results.get(0);
Assert.assertEquals(row.get("typeName"), "Person");
+
+ //verify limit and offset
+ //higher limit should return all results
+ results = new JSONArray(discoveryService.searchByFullText("Department", queryParams));
+ assertEquals(results.length(), 5);
+
+ //smaller limit should return those many rows
+ results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2, 0)));
+ assertEquals(results.length(), 2);
+
+ //offset should offset the results
+ results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(5, 2)));
+ assertEquals(results.length(), 3);
+
+ //higher offset shouldn't return any rows
+ results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2, 6)));
+ assertEquals(results.length(), 0);
}
private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance) throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
index 36a6808..ea87ee1 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
@@ -217,7 +217,6 @@ public class MetadataDiscoveryResource {
* @param query search query.
* @param limit number of rows to be returned in the result, used for pagination. maxlimit > limit > 0. -1 maps to atlas.search.defaultlimit property value
* @param offset offset to the results returned, used for pagination. offset >= 0. -1 maps to offset 0
- * NOTE: Pagination is not implemented currently for full text search, so limit and offset are not used
* @return JSON representing the type and results.
*/
@GET
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4bc3e738/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
index 606af92..067c161 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
@@ -86,10 +86,10 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
JSONArray results = response.getJSONArray(AtlasClient.RESULTS);
Assert.assertNotNull(results);
- assertEquals(results.length(), 1);
+ assertEquals(results.length(), 2);
int numRows = response.getInt(AtlasClient.COUNT);
- assertEquals(numRows, 1);
+ assertEquals(numRows, 2);
}
@Test
@@ -196,7 +196,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
assertEquals(response.getString("queryType"), "dsl");
}
- @Test
+ @Test(dependsOnMethods = "testSearchDSLLimits")
public void testSearchUsingFullText() throws Exception {
JSONObject response = serviceClient.searchByFullText(tagName, 10, 0);
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
@@ -214,6 +214,32 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
int numRows = response.getInt(AtlasClient.COUNT);
assertEquals(numRows, 1);
+
+ //API works without limit and offset
+ String query = "dsl_test_type";
+ WebResource resource = service.path("api/atlas/discovery/search/fulltext").queryParam("query", query);
+ ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
+ .method(HttpMethod.GET, ClientResponse.class);
+ assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
+ results = new JSONObject(clientResponse.getEntity(String.class)).getJSONArray(AtlasClient.RESULTS);
+ assertEquals(results.length(), 2);
+
+ //verify passed in limits and offsets are used
+ //higher limit and 0 offset returns all results
+ results = serviceClient.searchByFullText(query, 10, 0).getJSONArray(AtlasClient.RESULTS);
+ assertEquals(results.length(), 2);
+
+ //offset is used
+ results = serviceClient.searchByFullText(query, 10, 1).getJSONArray(AtlasClient.RESULTS);
+ assertEquals(results.length(), 1);
+
+ //limit is used
+ results = serviceClient.searchByFullText(query, 1, 0).getJSONArray(AtlasClient.RESULTS);
+ assertEquals(results.length(), 1);
+
+ //higher offset returns 0 results
+ results = serviceClient.searchByFullText(query, 1, 2).getJSONArray(AtlasClient.RESULTS);
+ assertEquals(results.length(), 0);
}
private void createTypes() throws Exception {