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
64bda5a4
Commit
64bda5a4
authored
9 years ago
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-471 Atlas Server could run out of memory due to Scala memory leak(yhemanth via sumasai)
parent
60ebe8be
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
44 deletions
+29
-44
GraphBackedDiscoveryService.java
...he/atlas/discovery/graph/GraphBackedDiscoveryService.java
+1
-2
QueryParser.scala
...y/src/main/scala/org/apache/atlas/query/QueryParser.scala
+2
-2
GremlinTest.scala
...y/src/test/scala/org/apache/atlas/query/GremlinTest.scala
+5
-5
GremlinTest2.scala
.../src/test/scala/org/apache/atlas/query/GremlinTest2.scala
+2
-2
LexerTest.scala
...ory/src/test/scala/org/apache/atlas/query/LexerTest.scala
+4
-5
ParserTest.scala
...ry/src/test/scala/org/apache/atlas/query/ParserTest.scala
+15
-28
No files found.
repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
View file @
64bda5a4
...
...
@@ -128,8 +128,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
public
GremlinQueryResult
evaluate
(
String
dslQuery
)
throws
DiscoveryException
{
LOG
.
info
(
"Executing dsl query={}"
,
dslQuery
);
try
{
QueryParser
queryParser
=
new
QueryParser
();
Either
<
Parsers
.
NoSuccess
,
Expressions
.
Expression
>
either
=
queryParser
.
apply
(
dslQuery
);
Either
<
Parsers
.
NoSuccess
,
Expressions
.
Expression
>
either
=
QueryParser
.
apply
(
dslQuery
);
if
(
either
.
isRight
())
{
Expressions
.
Expression
expression
=
either
.
right
().
get
();
return
evaluate
(
expression
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/scala/org/apache/atlas/query/QueryParser.scala
View file @
64bda5a4
...
...
@@ -107,7 +107,7 @@ trait ExpressionUtils {
}
}
class
QueryParser
extends
StandardTokenParsers
with
QueryKeywords
with
ExpressionUtils
with
PackratParsers
{
object
QueryParser
extends
StandardTokenParsers
with
QueryKeywords
with
ExpressionUtils
with
PackratParsers
{
import
scala.language.higherKinds
...
...
@@ -119,7 +119,7 @@ class QueryParser extends StandardTokenParsers with QueryKeywords with Expressio
override
val
lexical
=
new
QueryLexer
(
queryreservedWords
,
querydelims
)
def
apply
(
input
:
String
)
:
Either
[
NoSuccess
,
Expression
]
=
{
def
apply
(
input
:
String
)
:
Either
[
NoSuccess
,
Expression
]
=
synchronized
{
phrase
(
queryWithPath
)(
new
lexical
.
Scanner
(
input
))
match
{
case
Success
(
r
,
x
)
=>
Right
(
r
)
case
f
@Failure
(
m
,
x
)
=>
Left
(
f
)
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala
View file @
64bda5a4
...
...
@@ -899,7 +899,7 @@ class GremlinTest extends BaseGremlinTest {
}
@Test
def
testArrayComparision
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'sales_fact_daily_mv',"
+
" db where name = 'Reporting' and clusterName = 'test' select p"
).
right
.
get
...
...
@@ -937,7 +937,7 @@ class GremlinTest extends BaseGremlinTest {
}
@Test
def
testArrayComparisionWithSelectOnArray
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'sales_fact_daily_mv',"
+
" db where name = 'Reporting' and clusterName = 'test' select p.values"
).
right
.
get
...
...
@@ -976,7 +976,7 @@ class GremlinTest extends BaseGremlinTest {
}
@Test
def
testArrayInWhereClause
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01']"
).
right
.
get
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
validateJson
(
r
,
"""{
...
...
@@ -1045,13 +1045,13 @@ class GremlinTest extends BaseGremlinTest {
@Test
(
expectedExceptions
=
Array
(
classOf
[
ExpressionException
]))
def
testNegativeInvalidType
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"from blah"
).
right
.
get
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
}
@Test
def
testJoinAndSelect5
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Table as t where name = 'sales_fact' db where name = 'Sales' and owner = 'John ETL' select t"
).
right
.
get
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
validateJson
(
r
)
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala
View file @
64bda5a4
...
...
@@ -89,7 +89,7 @@ class GremlinTest2 extends BaseGremlinTest {
}
@Test
def
testLineageAllSelectWithPathFromParser
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Table as src loop (LoadProcess outputTable) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
//Table as src loop (LoadProcess where LoadProcess.outputTable) as dest select src.name as srcTable, dest.name as destTable withPath
...
...
@@ -98,7 +98,7 @@ class GremlinTest2 extends BaseGremlinTest {
}
@Test
def
testLineageAllSelectWithPathFromParser2
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Table as src loop (`LoadProcess->outputTable` inputTables) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/scala/org/apache/atlas/query/LexerTest.scala
View file @
64bda5a4
...
...
@@ -25,8 +25,8 @@ import scala.util.parsing.input.CharArrayReader
class
LexerTest
{
def
scan
(
p
:
QueryParser
,
str
:
String
)
:
p
.lexical.ParseResult
[
_
]
=
{
val
l
=
p
.
lexical
def
scan
(
str
:
String
)
:
QueryParser
.lexical.ParseResult
[
_
]
=
{
val
l
=
QueryParser
.
lexical
var
s
:
l.Input
=
new
CharArrayReader
(
str
.
toCharArray
)
var
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
s
=
r
.
next
...
...
@@ -37,12 +37,11 @@ class LexerTest {
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
}
}
r
.
asInstanceOf
[
p
.lexical.ParseResult
[
_
]]
r
.
asInstanceOf
[
QueryParser
.lexical.ParseResult
[
_
]]
}
@Test
def
testSimple
{
val
p
=
new
QueryParser
val
r
=
scan
(
p
,
"""DB where db1.name"""
)
val
r
=
scan
(
"""DB where db1.name"""
)
Assert
.
assertTrue
(
r
.
successful
)
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/scala/org/apache/atlas/query/ParserTest.scala
View file @
64bda5a4
...
...
@@ -31,74 +31,61 @@ class ParserTest extends BaseTest {
}
@Test
def
testFrom
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"from DB"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"from DB"
).
right
.
get
.
toString
)
}
@Test
def
testFrom2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"DB"
).
right
.
get
.
toString
)
}
@Test
def
testJoin1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB, Table"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"DB, Table"
).
right
.
get
.
toString
)
}
@Test
def
testWhere1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB as db1 Table where db1.name "
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"DB as db1 Table where db1.name "
).
right
.
get
.
toString
)
}
@Test
def
testWhere2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB name = \"Reporting\""
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"DB name = \"Reporting\""
).
right
.
get
.
toString
)
}
@Test
def
testIsTrait
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"Table isa Dimension"
).
right
.
get
.
toString
)
println
(
p
(
"Table is Dimension"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"Table isa Dimension"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"Table is Dimension"
).
right
.
get
.
toString
)
}
@Test
def
test4
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1"
).
right
.
get
.
toString
)
}
@Test
def
testJoin2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab "
+
println
(
QueryParser
.
apply
(
"DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab "
+
" select db1.name as dbName, tab.name as tabName"
).
right
.
get
.
toString
)
}
@Test
def
testLoop
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"Table loop (LoadProcess outputTable)"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"Table loop (LoadProcess outputTable)"
).
right
.
get
.
toString
)
}
@Test
def
testNegInvalidateType
:
Unit
=
{
val
p
=
new
QueryParser
val
x
=
p
(
"from blah"
)
println
(
p
(
"from blah"
).
left
)
val
x
=
QueryParser
.
apply
(
"from blah"
)
println
(
QueryParser
.
apply
(
"from blah"
).
left
)
}
@Test
def
testPath1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"Table loop (LoadProcess outputTable) withPath"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"Table loop (LoadProcess outputTable) withPath"
).
right
.
get
.
toString
)
}
@Test
def
testPath2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
println
(
QueryParser
.
apply
(
"Table as src loop (LoadProcess outputTable) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
.
toString
)
}
@Test
def
testList
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
println
(
QueryParser
.
apply
(
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'tableoq8ty',"
+
" db where name = 'default' and clusterName = 'test'"
).
right
.
get
.
toString
...
...
This diff is collapsed.
Click to expand it.
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