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
3af54364
Commit
3af54364
authored
Sep 28, 2017
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2184: IS_NULL, NOT_NULL operator support (#2)
parent
57fbb9ce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
SearchProcessor.java
...main/java/org/apache/atlas/discovery/SearchProcessor.java
+20
-9
AtlasGremlin2QueryProvider.java
...ava/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
+4
-0
AtlasGremlinQueryProvider.java
...java/org/apache/atlas/util/AtlasGremlinQueryProvider.java
+3
-1
No files found.
repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
View file @
3af54364
...
@@ -459,6 +459,7 @@ public abstract class SearchProcessor {
...
@@ -459,6 +459,7 @@ public abstract class SearchProcessor {
final
Class
attrClass
;
final
Class
attrClass
;
final
Object
attrValue
;
final
Object
attrValue
;
// Some operators support null comparison, thus the parsing has to be conditional
switch
(
attrType
.
getTypeName
())
{
switch
(
attrType
.
getTypeName
())
{
case
AtlasBaseTypeDef
.
ATLAS_TYPE_STRING
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_STRING
:
attrClass
=
String
.
class
;
attrClass
=
String
.
class
;
...
@@ -466,40 +467,40 @@ public abstract class SearchProcessor {
...
@@ -466,40 +467,40 @@ public abstract class SearchProcessor {
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_SHORT
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_SHORT
:
attrClass
=
Short
.
class
;
attrClass
=
Short
.
class
;
attrValue
=
Short
.
parseShort
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Short
.
parseShort
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_INT
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_INT
:
attrClass
=
Integer
.
class
;
attrClass
=
Integer
.
class
;
attrValue
=
Integer
.
parseInt
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Integer
.
parseInt
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BIGINTEGER
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BIGINTEGER
:
attrClass
=
BigInteger
.
class
;
attrClass
=
BigInteger
.
class
;
attrValue
=
new
BigInteger
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
new
BigInteger
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BOOLEAN
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BOOLEAN
:
attrClass
=
Boolean
.
class
;
attrClass
=
Boolean
.
class
;
attrValue
=
Boolean
.
parseBoolean
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Boolean
.
parseBoolean
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BYTE
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BYTE
:
attrClass
=
Byte
.
class
;
attrClass
=
Byte
.
class
;
attrValue
=
Byte
.
parseByte
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Byte
.
parseByte
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_LONG
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_LONG
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_DATE
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_DATE
:
attrClass
=
Long
.
class
;
attrClass
=
Long
.
class
;
attrValue
=
Long
.
parseLong
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Long
.
parseLong
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_FLOAT
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_FLOAT
:
attrClass
=
Float
.
class
;
attrClass
=
Float
.
class
;
attrValue
=
Float
.
parseFloat
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Float
.
parseFloat
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_DOUBLE
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_DOUBLE
:
attrClass
=
Double
.
class
;
attrClass
=
Double
.
class
;
attrValue
=
Double
.
parseDouble
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
Double
.
parseDouble
(
attrVal
);
break
;
break
;
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BIGDECIMAL
:
case
AtlasBaseTypeDef
.
ATLAS_TYPE_BIGDECIMAL
:
attrClass
=
BigDecimal
.
class
;
attrClass
=
BigDecimal
.
class
;
attrValue
=
new
BigDecimal
(
attrVal
);
attrValue
=
attrVal
==
null
?
null
:
new
BigDecimal
(
attrVal
);
break
;
break
;
default
:
default
:
if
(
attrType
instanceof
AtlasEnumType
)
{
if
(
attrType
instanceof
AtlasEnumType
)
{
...
@@ -637,6 +638,12 @@ public abstract class SearchProcessor {
...
@@ -637,6 +638,12 @@ public abstract class SearchProcessor {
case
CONTAINS:
case
CONTAINS:
queryTemplate
=
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
COMPARE_CONTAINS
);
queryTemplate
=
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
COMPARE_CONTAINS
);
break
;
break
;
case
IS_NULL:
queryTemplate
=
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
COMPARE_IS_NULL
);
break
;
case
NOT_NULL:
queryTemplate
=
queryProvider
.
getQuery
(
AtlasGremlinQueryProvider
.
AtlasGremlinQuery
.
COMPARE_NOT_NULL
);
break
;
}
}
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
(
queryTemplate
))
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
(
queryTemplate
))
{
...
@@ -695,6 +702,10 @@ public abstract class SearchProcessor {
...
@@ -695,6 +702,10 @@ public abstract class SearchProcessor {
}
}
private
static
boolean
hasIndexQuerySpecialChar
(
String
attributeValue
)
{
private
static
boolean
hasIndexQuerySpecialChar
(
String
attributeValue
)
{
if
(
attributeValue
==
null
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
attributeValue
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
attributeValue
.
length
();
i
++)
{
if
(
isIndexQuerySpecialChar
(
attributeValue
.
charAt
(
i
)))
{
if
(
isIndexQuerySpecialChar
(
attributeValue
.
charAt
(
i
)))
{
return
true
;
return
true
;
...
...
repository/src/main/java/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
View file @
3af54364
...
@@ -95,6 +95,10 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
...
@@ -95,6 +95,10 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
return
".filter({it.getProperty('%s').endsWith(%s)})"
;
return
".filter({it.getProperty('%s').endsWith(%s)})"
;
case
COMPARE_CONTAINS:
case
COMPARE_CONTAINS:
return
".filter({it.getProperty('%s').contains(%s)})"
;
return
".filter({it.getProperty('%s').contains(%s)})"
;
case
COMPARE_IS_NULL:
return
".hasNot('%s')"
;
case
COMPARE_NOT_NULL:
return
".has('%s')"
;
case
RELATIONSHIP_SEARCH:
case
RELATIONSHIP_SEARCH:
return
"g.V('__guid', guid).both(relation).has('__state', T.in, states)"
;
return
"g.V('__guid', guid).both(relation).has('__state', T.in, states)"
;
case
RELATIONSHIP_SEARCH_ASCENDING_SORT:
case
RELATIONSHIP_SEARCH_ASCENDING_SORT:
...
...
repository/src/main/java/org/apache/atlas/util/AtlasGremlinQueryProvider.java
View file @
3af54364
...
@@ -75,6 +75,8 @@ public abstract class AtlasGremlinQueryProvider {
...
@@ -75,6 +75,8 @@ public abstract class AtlasGremlinQueryProvider {
COMPARE_MATCHES
,
COMPARE_MATCHES
,
COMPARE_STARTS_WITH
,
COMPARE_STARTS_WITH
,
COMPARE_ENDS_WITH
,
COMPARE_ENDS_WITH
,
COMPARE_CONTAINS
COMPARE_CONTAINS
,
COMPARE_IS_NULL
,
COMPARE_NOT_NULL
}
}
}
}
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