Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
6ecad6e5
Commit
6ecad6e5
authored
Mar 06, 2020
by
Pinal Shah
Committed by
nixonrodrigues
Mar 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3618 : Entities with no guid appears in search result
Signed-off-by:
nixonrodrigues
<
nixon@apache.org
>
parent
765ea583
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
7 deletions
+58
-7
ClassificationSearchProcessor.java
...apache/atlas/discovery/ClassificationSearchProcessor.java
+8
-0
EntitySearchProcessor.java
...ava/org/apache/atlas/discovery/EntitySearchProcessor.java
+14
-7
SearchPredicateUtil.java
.../main/java/org/apache/atlas/util/SearchPredicateUtil.java
+36
-0
No files found.
repository/src/main/java/org/apache/atlas/discovery/ClassificationSearchProcessor.java
View file @
6ecad6e5
...
...
@@ -70,6 +70,7 @@ public class ClassificationSearchProcessor extends SearchProcessor {
private
final
Map
<
String
,
Object
>
gremlinQueryBindings
;
private
final
String
gremlinTagFilterQuery
;
private
final
Predicate
traitPredicate
;
private
final
Predicate
isEntityPredicate
;
// Some index engines may take space as a delimiter, when basic search is
// executed, unsatisfying results may be returned.
...
...
@@ -148,12 +149,14 @@ public class ClassificationSearchProcessor extends SearchProcessor {
LOG
.
debug
(
"Using query string '{}'."
,
indexQuery
);
isEntityPredicate
=
SearchPredicateUtil
.
generateIsEntityVertexPredicate
(
context
.
getTypeRegistry
());
traitPredicate
=
buildTraitPredict
(
classificationType
);
inMemoryPredicate
=
inMemoryPredicate
==
null
?
traitPredicate
:
PredicateUtils
.
andPredicate
(
inMemoryPredicate
,
traitPredicate
);
}
else
{
indexQuery
=
null
;
traitPredicate
=
null
;
isEntityPredicate
=
null
;
}
// index query directly on classification
...
...
@@ -282,6 +285,11 @@ public class ClassificationSearchProcessor extends SearchProcessor {
getVerticesFromIndexQueryResult
(
queryResult
,
entityVertices
);
isLastResultPage
=
entityVertices
.
size
()
<
limit
;
if
(
isEntityPredicate
!=
null
)
{
// Do in-memory filtering
CollectionUtils
.
filter
(
entityVertices
,
isEntityPredicate
);
}
}
else
{
if
(
classificationIndexQuery
!=
null
)
{
Iterator
<
AtlasIndexQuery
.
Result
>
queryResult
=
classificationIndexQuery
.
vertices
(
qryOffset
,
limit
);
...
...
repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
View file @
6ecad6e5
...
...
@@ -97,7 +97,7 @@ public class EntitySearchProcessor extends SearchProcessor {
if
(!
isEntityRootType
())
{
typeNamePredicate
=
SearchPredicateUtil
.
getINPredicateGenerator
().
generatePredicate
(
TYPE_NAME_PROPERTY_KEY
,
typeAndSubTypes
,
String
.
class
);
}
else
{
typeNamePredicate
=
null
;
typeNamePredicate
=
SearchPredicateUtil
.
generateIsEntityVertexPredicate
(
context
.
getTypeRegistry
())
;
}
processSearchAttributes
(
entityType
,
filterCriteria
,
indexAttributes
,
graphAttributes
,
allAttributes
);
...
...
@@ -111,9 +111,8 @@ public class EntitySearchProcessor extends SearchProcessor {
graphIndexQueryBuilder
.
addTypeAndSubTypesQueryFilter
(
indexQuery
,
typeAndSubTypesQryStr
);
// TypeName check to be done in-memory as well to address ATLAS-2121 (case sensitivity)
if
(
typeNamePredicate
!=
null
)
{
inMemoryPredicate
=
typeNamePredicate
;
}
inMemoryPredicate
=
typeNamePredicate
;
}
if
(
attrSearchByIndex
)
{
...
...
@@ -168,6 +167,10 @@ public class EntitySearchProcessor extends SearchProcessor {
query
.
or
(
orConditions
);
// Construct a parallel in-memory predicate
if
(
isEntityRootType
())
{
inMemoryPredicate
=
typeNamePredicate
;
}
if
(
graphQueryPredicate
!=
null
)
{
graphQueryPredicate
=
PredicateUtils
.
andPredicate
(
graphQueryPredicate
,
traitPredicate
);
}
else
{
...
...
@@ -210,9 +213,8 @@ public class EntitySearchProcessor extends SearchProcessor {
}
// Prepare the graph query and in-memory filter for the filtering phase
if
(
typeNamePredicate
!=
null
)
{
filterGraphQueryPredicate
=
typeNamePredicate
;
}
filterGraphQueryPredicate
=
typeNamePredicate
;
Predicate
attributesPredicate
=
constructInMemoryPredicate
(
entityType
,
filterCriteria
,
allAttributes
);
...
...
@@ -311,6 +313,11 @@ public class EntitySearchProcessor extends SearchProcessor {
isLastResultPage
=
entityVertices
.
size
()
<
limit
;
// Do in-memory filtering
if
(
inMemoryPredicate
!=
null
)
{
CollectionUtils
.
filter
(
entityVertices
,
inMemoryPredicate
);
}
//incase when operator is NEQ in pipeSeperatedSystemAttributes
if
(
graphQueryPredicate
!=
null
)
{
CollectionUtils
.
filter
(
entityVertices
,
graphQueryPredicate
);
...
...
repository/src/main/java/org/apache/atlas/util/SearchPredicateUtil.java
View file @
6ecad6e5
...
...
@@ -19,6 +19,8 @@ package org.apache.atlas.util;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -1354,4 +1356,38 @@ public class SearchPredicateUtil {
};
}
}
public
static
Predicate
generateIsEntityVertexPredicate
(
AtlasTypeRegistry
typeRegistry
)
{
return
new
IsEntityVertexPredicate
(
typeRegistry
);
}
static
class
IsEntityVertexPredicate
implements
Predicate
{
final
AtlasTypeRegistry
typeRegistry
;
public
IsEntityVertexPredicate
(
AtlasTypeRegistry
typeRegistry
)
{
this
.
typeRegistry
=
typeRegistry
;
}
@Override
public
boolean
evaluate
(
final
Object
object
)
{
final
boolean
ret
;
AtlasVertex
vertex
=
(
object
instanceof
AtlasVertex
)
?
(
AtlasVertex
)
object
:
null
;
if
(
vertex
!=
null
)
{
String
typeName
=
AtlasGraphUtilsV2
.
getTypeName
(
vertex
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
ret
=
entityType
!=
null
&&
!
entityType
.
isInternalType
();
}
else
{
ret
=
false
;
}
return
ret
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment