You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/09/22 02:10:35 UTC

[7/7] atlas git commit: ATLAS-2121: basic-search update to use case-sensitive filter for type-name / tag-name

ATLAS-2121: basic-search update to use case-sensitive filter for type-name / tag-name

Signed-off-by: Madhan Neethiraj <ma...@apache.org>
(cherry picked from commit c0f0abc13037a9d05499dbce2d0e1b65beb9d656)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/466703fe
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/466703fe
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/466703fe

Branch: refs/heads/branch-0.8
Commit: 466703fe86df3db0f203cbda5847dfbfc160b5af
Parents: 4f1129b
Author: apoorvnaik <ap...@apache.org>
Authored: Tue Sep 19 11:57:01 2017 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Thu Sep 21 19:10:04 2017 -0700

----------------------------------------------------------------------
 .../discovery/ClassificationSearchProcessor.java   | 10 +++++++++-
 .../atlas/discovery/EntitySearchProcessor.java     | 17 +++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/466703fe/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
index 1d4815d..776f5bf 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
@@ -34,6 +34,7 @@ import org.apache.atlas.util.SearchPredicateUtil;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.PredicateUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -93,7 +94,14 @@ public class ClassificationSearchProcessor extends SearchProcessor {
 
             this.indexQuery = graph.indexQuery(Constants.VERTEX_INDEX, indexQueryString);
 
-            inMemoryPredicate = constructInMemoryPredicate(classificationType, filterCriteria, indexAttributes);
+            Predicate typeNamePredicate  = SearchPredicateUtil.getINPredicateGenerator()
+                                                              .generatePredicate(Constants.TYPE_NAME_PROPERTY_KEY, typeAndSubTypes, String.class);
+            Predicate attributePredicate = constructInMemoryPredicate(classificationType, filterCriteria, indexAttributes);
+            if (attributePredicate != null) {
+                inMemoryPredicate = PredicateUtils.andPredicate(typeNamePredicate, attributePredicate);
+            } else {
+                inMemoryPredicate = typeNamePredicate;
+            }
         } else {
             indexQuery = null;
         }

http://git-wip-us.apache.org/repos/asf/atlas/blob/466703fe/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
index 970cd28..87efed7 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
@@ -80,12 +80,20 @@ public class EntitySearchProcessor extends SearchProcessor {
 
         if (typeSearchByIndex) {
             constructTypeTestQuery(indexQuery, typeAndSubTypesQryStr);
+
+            // TypeName check to be done in-memory as well to address ATLAS-2121 (case sensitivity)
+            inMemoryPredicate = typeNamePredicate;
         }
 
         if (attrSearchByIndex) {
             constructFilterQuery(indexQuery, entityType, filterCriteria, indexAttributes);
 
-            inMemoryPredicate = constructInMemoryPredicate(entityType, filterCriteria, indexAttributes);
+            Predicate attributePredicate = constructInMemoryPredicate(entityType, filterCriteria, indexAttributes);
+            if (inMemoryPredicate != null) {
+                inMemoryPredicate = PredicateUtils.andPredicate(inMemoryPredicate, attributePredicate);
+            } else {
+                inMemoryPredicate = attributePredicate;
+            }
         } else {
             graphAttributes.addAll(indexAttributes);
         }
@@ -110,13 +118,6 @@ public class EntitySearchProcessor extends SearchProcessor {
 
             if (!typeSearchByIndex) {
                 query.in(Constants.TYPE_NAME_PROPERTY_KEY, typeAndSubTypes);
-
-                // Construct a parallel in-memory predicate
-                if (graphQueryPredicate != null) {
-                    graphQueryPredicate = PredicateUtils.andPredicate(graphQueryPredicate, typeNamePredicate);
-                } else {
-                    graphQueryPredicate = typeNamePredicate;
-                }
             }
 
             // If we need to filter on the trait names then we need to build the query and equivalent in-memory predicate