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
Feb 17, 2016
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
Show 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 {
...
@@ -128,8 +128,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
public
GremlinQueryResult
evaluate
(
String
dslQuery
)
throws
DiscoveryException
{
public
GremlinQueryResult
evaluate
(
String
dslQuery
)
throws
DiscoveryException
{
LOG
.
info
(
"Executing dsl query={}"
,
dslQuery
);
LOG
.
info
(
"Executing dsl query={}"
,
dslQuery
);
try
{
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
())
{
if
(
either
.
isRight
())
{
Expressions
.
Expression
expression
=
either
.
right
().
get
();
Expressions
.
Expression
expression
=
either
.
right
().
get
();
return
evaluate
(
expression
);
return
evaluate
(
expression
);
...
...
repository/src/main/scala/org/apache/atlas/query/QueryParser.scala
View file @
64bda5a4
...
@@ -107,7 +107,7 @@ trait ExpressionUtils {
...
@@ -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
import
scala.language.higherKinds
...
@@ -119,7 +119,7 @@ class QueryParser extends StandardTokenParsers with QueryKeywords with Expressio
...
@@ -119,7 +119,7 @@ class QueryParser extends StandardTokenParsers with QueryKeywords with Expressio
override
val
lexical
=
new
QueryLexer
(
queryreservedWords
,
querydelims
)
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
{
phrase
(
queryWithPath
)(
new
lexical
.
Scanner
(
input
))
match
{
case
Success
(
r
,
x
)
=>
Right
(
r
)
case
Success
(
r
,
x
)
=>
Right
(
r
)
case
f
@Failure
(
m
,
x
)
=>
Left
(
f
)
case
f
@Failure
(
m
,
x
)
=>
Left
(
f
)
...
...
repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala
View file @
64bda5a4
...
@@ -899,7 +899,7 @@ class GremlinTest extends BaseGremlinTest {
...
@@ -899,7 +899,7 @@ class GremlinTest extends BaseGremlinTest {
}
}
@Test
def
testArrayComparision
{
@Test
def
testArrayComparision
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'sales_fact_daily_mv',"
+
" table where name = 'sales_fact_daily_mv',"
+
" db where name = 'Reporting' and clusterName = 'test' select p"
).
right
.
get
" db where name = 'Reporting' and clusterName = 'test' select p"
).
right
.
get
...
@@ -937,7 +937,7 @@ class GremlinTest extends BaseGremlinTest {
...
@@ -937,7 +937,7 @@ class GremlinTest extends BaseGremlinTest {
}
}
@Test
def
testArrayComparisionWithSelectOnArray
{
@Test
def
testArrayComparisionWithSelectOnArray
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
val
e
=
p
(
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'sales_fact_daily_mv',"
+
" table where name = 'sales_fact_daily_mv',"
+
" db where name = 'Reporting' and clusterName = 'test' select p.values"
).
right
.
get
" db where name = 'Reporting' and clusterName = 'test' select p.values"
).
right
.
get
...
@@ -976,7 +976,7 @@ class GremlinTest extends BaseGremlinTest {
...
@@ -976,7 +976,7 @@ class GremlinTest extends BaseGremlinTest {
}
}
@Test
def
testArrayInWhereClause
{
@Test
def
testArrayInWhereClause
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Partition as p where values = ['2015-01-01']"
).
right
.
get
val
e
=
p
(
"Partition as p where values = ['2015-01-01']"
).
right
.
get
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
validateJson
(
r
,
"""{
validateJson
(
r
,
"""{
...
@@ -1045,13 +1045,13 @@ class GremlinTest extends BaseGremlinTest {
...
@@ -1045,13 +1045,13 @@ class GremlinTest extends BaseGremlinTest {
@Test
(
expectedExceptions
=
Array
(
classOf
[
ExpressionException
]))
@Test
(
expectedExceptions
=
Array
(
classOf
[
ExpressionException
]))
def
testNegativeInvalidType
{
def
testNegativeInvalidType
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"from blah"
).
right
.
get
val
e
=
p
(
"from blah"
).
right
.
get
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
}
}
@Test
def
testJoinAndSelect5
{
@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
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
)
val
r
=
QueryProcessor
.
evaluate
(
e
,
g
,
gp
)
validateJson
(
r
)
validateJson
(
r
)
...
...
repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala
View file @
64bda5a4
...
@@ -89,7 +89,7 @@ class GremlinTest2 extends BaseGremlinTest {
...
@@ -89,7 +89,7 @@ class GremlinTest2 extends BaseGremlinTest {
}
}
@Test
def
testLineageAllSelectWithPathFromParser
{
@Test
def
testLineageAllSelectWithPathFromParser
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Table as src loop (LoadProcess outputTable) as dest "
+
val
e
=
p
(
"Table as src loop (LoadProcess outputTable) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
"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
//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 {
...
@@ -98,7 +98,7 @@ class GremlinTest2 extends BaseGremlinTest {
}
}
@Test
def
testLineageAllSelectWithPathFromParser2
{
@Test
def
testLineageAllSelectWithPathFromParser2
{
val
p
=
new
QueryParser
val
p
=
QueryParser
val
e
=
p
(
"Table as src loop (`LoadProcess->outputTable` inputTables) as dest "
+
val
e
=
p
(
"Table as src loop (`LoadProcess->outputTable` inputTables) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
...
...
repository/src/test/scala/org/apache/atlas/query/LexerTest.scala
View file @
64bda5a4
...
@@ -25,8 +25,8 @@ import scala.util.parsing.input.CharArrayReader
...
@@ -25,8 +25,8 @@ import scala.util.parsing.input.CharArrayReader
class
LexerTest
{
class
LexerTest
{
def
scan
(
p
:
QueryParser
,
str
:
String
)
:
p
.lexical.ParseResult
[
_
]
=
{
def
scan
(
str
:
String
)
:
QueryParser
.lexical.ParseResult
[
_
]
=
{
val
l
=
p
.
lexical
val
l
=
QueryParser
.
lexical
var
s
:
l.Input
=
new
CharArrayReader
(
str
.
toCharArray
)
var
s
:
l.Input
=
new
CharArrayReader
(
str
.
toCharArray
)
var
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
var
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
s
=
r
.
next
s
=
r
.
next
...
@@ -37,12 +37,11 @@ class LexerTest {
...
@@ -37,12 +37,11 @@ class LexerTest {
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
}
}
}
}
r
.
asInstanceOf
[
p
.lexical.ParseResult
[
_
]]
r
.
asInstanceOf
[
QueryParser
.lexical.ParseResult
[
_
]]
}
}
@Test
def
testSimple
{
@Test
def
testSimple
{
val
p
=
new
QueryParser
val
r
=
scan
(
"""DB where db1.name"""
)
val
r
=
scan
(
p
,
"""DB where db1.name"""
)
Assert
.
assertTrue
(
r
.
successful
)
Assert
.
assertTrue
(
r
.
successful
)
}
}
...
...
repository/src/test/scala/org/apache/atlas/query/ParserTest.scala
View file @
64bda5a4
...
@@ -31,74 +31,61 @@ class ParserTest extends BaseTest {
...
@@ -31,74 +31,61 @@ class ParserTest extends BaseTest {
}
}
@Test
def
testFrom
:
Unit
=
{
@Test
def
testFrom
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"from DB"
).
right
.
get
.
toString
)
println
(
p
(
"from DB"
).
right
.
get
.
toString
)
}
}
@Test
def
testFrom2
:
Unit
=
{
@Test
def
testFrom2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB"
).
right
.
get
.
toString
)
println
(
p
(
"DB"
).
right
.
get
.
toString
)
}
}
@Test
def
testJoin1
:
Unit
=
{
@Test
def
testJoin1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB, Table"
).
right
.
get
.
toString
)
println
(
p
(
"DB, Table"
).
right
.
get
.
toString
)
}
}
@Test
def
testWhere1
:
Unit
=
{
@Test
def
testWhere1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB as db1 Table where db1.name "
).
right
.
get
.
toString
)
println
(
p
(
"DB as db1 Table where db1.name "
).
right
.
get
.
toString
)
}
}
@Test
def
testWhere2
:
Unit
=
{
@Test
def
testWhere2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB name = \"Reporting\""
).
right
.
get
.
toString
)
println
(
p
(
"DB name = \"Reporting\""
).
right
.
get
.
toString
)
}
}
@Test
def
testIsTrait
:
Unit
=
{
@Test
def
testIsTrait
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"Table isa Dimension"
).
right
.
get
.
toString
)
println
(
p
(
"Table isa Dimension"
).
right
.
get
.
toString
)
println
(
QueryParser
.
apply
(
"Table is Dimension"
).
right
.
get
.
toString
)
println
(
p
(
"Table is Dimension"
).
right
.
get
.
toString
)
}
}
@Test
def
test4
:
Unit
=
{
@Test
def
test4
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1"
).
right
.
get
.
toString
)
println
(
p
(
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1"
).
right
.
get
.
toString
)
}
}
@Test
def
testJoin2
:
Unit
=
{
@Test
def
testJoin2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab "
+
println
(
p
(
"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
)
" select db1.name as dbName, tab.name as tabName"
).
right
.
get
.
toString
)
}
}
@Test
def
testLoop
:
Unit
=
{
@Test
def
testLoop
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"Table loop (LoadProcess outputTable)"
).
right
.
get
.
toString
)
println
(
p
(
"Table loop (LoadProcess outputTable)"
).
right
.
get
.
toString
)
}
}
@Test
def
testNegInvalidateType
:
Unit
=
{
@Test
def
testNegInvalidateType
:
Unit
=
{
val
p
=
new
QueryParser
val
x
=
QueryParser
.
apply
(
"from blah"
)
val
x
=
p
(
"from blah"
)
println
(
QueryParser
.
apply
(
"from blah"
).
left
)
println
(
p
(
"from blah"
).
left
)
}
}
@Test
def
testPath1
:
Unit
=
{
@Test
def
testPath1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
"Table loop (LoadProcess outputTable) withPath"
).
right
.
get
.
toString
)
println
(
p
(
"Table loop (LoadProcess outputTable) withPath"
).
right
.
get
.
toString
)
}
}
@Test
def
testPath2
:
Unit
=
{
@Test
def
testPath2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
println
(
p
(
"Table as src loop (LoadProcess outputTable) as dest "
+
"Table as src loop (LoadProcess outputTable) as dest "
+
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
.
toString
"select src.name as srcTable, dest.name as destTable withPath"
).
right
.
get
.
toString
)
)
}
}
@Test
def
testList
:
Unit
=
{
@Test
def
testList
:
Unit
=
{
val
p
=
new
QueryParser
println
(
QueryParser
.
apply
(
println
(
p
(
"Partition as p where values = ['2015-01-01'],"
+
"Partition as p where values = ['2015-01-01'],"
+
" table where name = 'tableoq8ty',"
+
" table where name = 'tableoq8ty',"
+
" db where name = 'default' and clusterName = 'test'"
).
right
.
get
.
toString
" db where name = 'default' and clusterName = 'test'"
).
right
.
get
.
toString
...
...
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