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
f5f9fa09
Commit
f5f9fa09
authored
8 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1586: type search improvement by avoiding unnecessary instantiation of type objects
parent
e7eaa996
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
21 additions
and
228 deletions
+21
-228
AtlasClassificationDefStore.java
...s/repository/store/graph/AtlasClassificationDefStore.java
+0
-2
AtlasEntityDefStore.java
...che/atlas/repository/store/graph/AtlasEntityDefStore.java
+0
-2
AtlasEnumDefStore.java
...pache/atlas/repository/store/graph/AtlasEnumDefStore.java
+0
-2
AtlasStructDefStore.java
...che/atlas/repository/store/graph/AtlasStructDefStore.java
+0
-2
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+14
-64
AtlasClassificationDefStoreV1.java
...ository/store/graph/v1/AtlasClassificationDefStoreV1.java
+0
-28
AtlasEntityDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+0
-29
AtlasEnumDefStoreV1.java
.../atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
+0
-29
AtlasStructDefStoreV1.java
...tlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+0
-29
FilterUtil.java
...ain/java/org/apache/atlas/repository/util/FilterUtil.java
+7
-41
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasClassificationDefStore.java
View file @
f5f9fa09
...
...
@@ -51,6 +51,4 @@ public interface AtlasClassificationDefStore {
Object
preDeleteByGuid
(
String
guid
)
throws
AtlasBaseException
;
void
deleteByGuid
(
String
guid
,
Object
preDeleteResult
)
throws
AtlasBaseException
;
AtlasClassificationDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
;
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStore.java
View file @
f5f9fa09
...
...
@@ -51,6 +51,4 @@ public interface AtlasEntityDefStore {
Object
preDeleteByGuid
(
String
guid
)
throws
AtlasBaseException
;
void
deleteByGuid
(
String
guid
,
Object
preDeleteResult
)
throws
AtlasBaseException
;
AtlasEntityDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
;
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEnumDefStore.java
View file @
f5f9fa09
...
...
@@ -45,6 +45,4 @@ public interface AtlasEnumDefStore {
void
deleteByName
(
String
name
)
throws
AtlasBaseException
;
void
deleteByGuid
(
String
guid
)
throws
AtlasBaseException
;
AtlasEnumDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
;
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasStructDefStore.java
View file @
f5f9fa09
...
...
@@ -51,6 +51,4 @@ public interface AtlasStructDefStore {
Object
preDeleteByGuid
(
String
name
)
throws
AtlasBaseException
;
void
deleteByGuid
(
String
guid
,
Object
preDeleteResult
)
throws
AtlasBaseException
;
AtlasStructDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
;
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
f5f9fa09
...
...
@@ -552,79 +552,29 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
{
final
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
Predicate
searchPredicates
=
FilterUtil
.
getPredicateFromSearchFilter
(
searchFilter
);
try
{
List
<
AtlasEnumDef
>
enumDefs
=
getEnumDefStore
(
typeRegistry
).
getAll
();
CollectionUtils
.
filter
(
enumDefs
,
searchPredicates
);
typesDef
.
setEnumDefs
(
enumDefs
);
}
catch
(
AtlasBaseException
ex
)
{
LOG
.
error
(
"Failed to retrieve the EnumDefs"
,
ex
);
}
try
{
List
<
AtlasStructDef
>
structDefs
=
getStructDefStore
(
typeRegistry
).
getAll
();
Collection
typeCollection
=
CollectionUtils
.
collect
(
structDefs
,
new
Transformer
()
{
@Override
public
Object
transform
(
Object
o
)
{
try
{
return
new
AtlasStructType
((
AtlasStructDef
)
o
,
typeRegistry
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
warn
(
"Type validation failed for {}"
,
((
AtlasStructDef
)
o
).
getName
(),
e
);
return
null
;
}
}
});
CollectionUtils
.
filter
(
typeCollection
,
searchPredicates
);
for
(
Object
o
:
typeCollection
)
{
if
(
o
!=
null
)
typesDef
.
getStructDefs
().
add
(((
AtlasStructType
)
o
).
getStructDef
());
for
(
AtlasEnumType
enumType
:
typeRegistry
.
getAllEnumTypes
())
{
if
(
searchPredicates
.
evaluate
(
enumType
))
{
typesDef
.
getEnumDefs
().
add
(
enumType
.
getEnumDef
());
}
}
catch
(
AtlasBaseException
ex
)
{
LOG
.
error
(
"Failed to retrieve the StructDefs"
,
ex
);
}
try
{
List
<
AtlasClassificationDef
>
classificationDefs
=
getClassificationDefStore
(
typeRegistry
).
getAll
();
for
(
AtlasStructType
structType
:
typeRegistry
.
getAllStructTypes
())
{
if
(
searchPredicates
.
evaluate
(
structType
))
{
typesDef
.
getStructDefs
().
add
(
structType
.
getStructDef
());
}
}
Collection
typeCollection
=
CollectionUtils
.
collect
(
classificationDefs
,
new
Transformer
()
{
@Override
public
Object
transform
(
Object
o
)
{
try
{
return
new
AtlasClassificationType
((
AtlasClassificationDef
)
o
,
typeRegistry
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
warn
(
"Type validation failed for {}"
,
((
AtlasClassificationDef
)
o
).
getName
(),
e
);
return
null
;
}
}
});
CollectionUtils
.
filter
(
typeCollection
,
searchPredicates
);
for
(
Object
o
:
typeCollection
)
{
if
(
o
!=
null
)
typesDef
.
getClassificationDefs
().
add
(((
AtlasClassificationType
)
o
).
getClassificationDef
());
for
(
AtlasClassificationType
classificationType
:
typeRegistry
.
getAllClassificationTypes
())
{
if
(
searchPredicates
.
evaluate
(
classificationType
))
{
typesDef
.
getClassificationDefs
().
add
(
classificationType
.
getClassificationDef
());
}
}
catch
(
AtlasBaseException
ex
)
{
LOG
.
error
(
"Failed to retrieve the ClassificationDefs"
,
ex
);
}
try
{
List
<
AtlasEntityDef
>
entityDefs
=
getEntityDefStore
(
typeRegistry
).
getAll
();
Collection
typeCollection
=
CollectionUtils
.
collect
(
entityDefs
,
new
Transformer
()
{
@Override
public
Object
transform
(
Object
o
)
{
try
{
return
new
AtlasEntityType
((
AtlasEntityDef
)
o
,
typeRegistry
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
warn
(
"Type validation failed for {}"
,
((
AtlasEntityDef
)
o
).
getName
(),
e
);
return
null
;
}
}
});
CollectionUtils
.
filter
(
typeCollection
,
searchPredicates
);
for
(
Object
o
:
typeCollection
)
{
if
(
o
!=
null
)
typesDef
.
getEntityDefs
().
add
(((
AtlasEntityType
)
o
).
getEntityDef
());
for
(
AtlasEntityType
entityType
:
typeRegistry
.
getAllEntityTypes
())
{
if
(
searchPredicates
.
evaluate
(
entityType
))
{
typesDef
.
getEntityDefs
().
add
(
entityType
.
getEntityDef
());
}
}
catch
(
AtlasBaseException
ex
)
{
LOG
.
error
(
"Failed to retrieve the EntityDefs"
,
ex
);
}
return
typesDef
;
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
View file @
f5f9fa09
...
...
@@ -338,34 +338,6 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
}
}
@Override
public
AtlasClassificationDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasClassificationDefStoreV1.search({})"
,
filter
);
}
List
<
AtlasClassificationDef
>
classificationDefs
=
new
ArrayList
<>();
Iterator
<
AtlasVertex
>
vertices
=
typeDefStore
.
findTypeVerticesByCategory
(
TypeCategory
.
TRAIT
);
while
(
vertices
.
hasNext
())
{
AtlasVertex
vertex
=
vertices
.
next
();
AtlasClassificationDef
classificationDef
=
toClassificationDef
(
vertex
);
if
(
classificationDef
!=
null
)
{
classificationDefs
.
add
(
classificationDef
);
}
}
CollectionUtils
.
filter
(
classificationDefs
,
FilterUtil
.
getPredicateFromSearchFilter
(
filter
));
AtlasClassificationDefs
ret
=
new
AtlasClassificationDefs
(
classificationDefs
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasClassificationDefStoreV1.search({}): {}"
,
filter
,
ret
);
}
return
ret
;
}
private
void
updateVertexPreCreate
(
AtlasClassificationDef
classificationDef
,
AtlasClassificationType
classificationType
,
AtlasVertex
vertex
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
View file @
f5f9fa09
...
...
@@ -336,35 +336,6 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
}
}
@Override
public
AtlasEntityDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasEntityDefStoreV1.search({})"
,
filter
);
}
List
<
AtlasEntityDef
>
entityDefs
=
new
ArrayList
<>();
Iterator
<
AtlasVertex
>
vertices
=
typeDefStore
.
findTypeVerticesByCategory
(
TypeCategory
.
CLASS
);
while
(
vertices
.
hasNext
())
{
AtlasVertex
vertex
=
vertices
.
next
();
AtlasEntityDef
entityDef
=
toEntityDef
(
vertex
);
if
(
entityDef
!=
null
)
{
entityDefs
.
add
(
entityDef
);
}
}
CollectionUtils
.
filter
(
entityDefs
,
FilterUtil
.
getPredicateFromSearchFilter
(
filter
));
AtlasEntityDefs
ret
=
new
AtlasEntityDefs
(
entityDefs
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasEntityDefStoreV1.search({}): {}"
,
filter
,
ret
);
}
return
ret
;
}
private
void
updateVertexPreCreate
(
AtlasEntityDef
entityDef
,
AtlasEntityType
entityType
,
AtlasVertex
vertex
)
{
AtlasStructDefStoreV1
.
updateVertexPreCreate
(
entityDef
,
entityType
,
vertex
,
typeDefStore
);
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
View file @
f5f9fa09
...
...
@@ -250,35 +250,6 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
}
}
@Override
public
AtlasEnumDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasEnumDefStoreV1.search({})"
,
filter
);
}
List
<
AtlasEnumDef
>
enumDefs
=
new
ArrayList
<>();
Iterator
<
AtlasVertex
>
vertices
=
typeDefStore
.
findTypeVerticesByCategory
(
TypeCategory
.
ENUM
);
while
(
vertices
.
hasNext
())
{
AtlasVertex
vertex
=
vertices
.
next
();
AtlasEnumDef
enumDef
=
toEnumDef
(
vertex
);
if
(
enumDef
!=
null
)
{
enumDefs
.
add
(
enumDef
);
}
}
CollectionUtils
.
filter
(
enumDefs
,
FilterUtil
.
getPredicateFromSearchFilter
(
filter
));
AtlasEnumDefs
ret
=
new
AtlasEnumDefs
(
enumDefs
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasEnumDefStoreV1.search({}): {}"
,
filter
,
ret
);
}
return
ret
;
}
private
void
toVertex
(
AtlasEnumDef
enumDef
,
AtlasVertex
vertex
)
{
List
<
String
>
values
=
new
ArrayList
<>(
enumDef
.
getElementDefs
().
size
());
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
View file @
f5f9fa09
...
...
@@ -347,35 +347,6 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
}
}
@Override
public
AtlasStructDefs
search
(
SearchFilter
filter
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AtlasStructDefStoreV1.search({})"
,
filter
);
}
List
<
AtlasStructDef
>
structDefs
=
new
ArrayList
<>();
Iterator
<
AtlasVertex
>
vertices
=
typeDefStore
.
findTypeVerticesByCategory
(
TypeCategory
.
STRUCT
);
while
(
vertices
.
hasNext
())
{
AtlasVertex
vertex
=
vertices
.
next
();
AtlasStructDef
structDef
=
toStructDef
(
vertex
);
if
(
structDef
!=
null
)
{
structDefs
.
add
(
structDef
);
}
}
CollectionUtils
.
filter
(
structDefs
,
FilterUtil
.
getPredicateFromSearchFilter
(
filter
));
AtlasStructDefs
ret
=
new
AtlasStructDefs
(
structDefs
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasStructDefStoreV1.search({}): {}"
,
filter
,
ret
);
}
return
ret
;
}
private
AtlasStructDef
toStructDef
(
AtlasVertex
vertex
)
throws
AtlasBaseException
{
AtlasStructDef
ret
=
null
;
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/util/FilterUtil.java
View file @
f5f9fa09
...
...
@@ -37,9 +37,10 @@ import java.util.Objects;
public
class
FilterUtil
{
public
static
Predicate
getPredicateFromSearchFilter
(
SearchFilter
searchFilter
)
{
List
<
Predicate
>
predicates
=
new
ArrayList
<>();
final
String
type
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_TYPE
);
final
String
name
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_NAME
);
final
String
supertype
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_SUPERTYPE
);
final
String
type
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_TYPE
);
final
String
name
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_NAME
);
final
String
supertype
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_SUPERTYPE
);
final
String
notSupertype
=
searchFilter
.
getParam
(
SearchFilter
.
PARAM_NOT_SUPERTYPE
);
// Add filter for the type/category
...
...
@@ -71,33 +72,19 @@ public class FilterUtil {
return
o
instanceof
AtlasType
;
}
private
boolean
isAtlasTypeDef
(
Object
o
)
{
return
o
instanceof
AtlasBaseTypeDef
;
}
@Override
public
boolean
evaluate
(
Object
o
)
{
return
o
!=
null
&&
(
isAtlasType
(
o
)
&&
Objects
.
equals
(((
AtlasType
)
o
).
getTypeName
(),
name
))
||
(
isAtlasTypeDef
(
o
)
&&
Objects
.
equals
(((
AtlasBaseTypeDef
)
o
).
getName
(),
name
));
return
o
!=
null
&&
isAtlasType
(
o
)
&&
Objects
.
equals
(((
AtlasType
)
o
).
getTypeName
(),
name
);
}
};
}
private
static
Predicate
getSuperTypePredicate
(
final
String
supertype
)
{
return
new
Predicate
()
{
private
boolean
isClassificationTypeDef
(
Object
o
)
{
return
o
instanceof
AtlasClassificationDef
;
}
private
boolean
isClassificationType
(
Object
o
)
{
return
o
instanceof
AtlasClassificationType
;
}
private
boolean
isEntityTypeDef
(
Object
o
)
{
return
o
instanceof
AtlasEntityDef
;
}
private
boolean
isEntityType
(
Object
o
)
{
return
o
instanceof
AtlasEntityType
;
}
...
...
@@ -105,9 +92,7 @@ public class FilterUtil {
@Override
public
boolean
evaluate
(
Object
o
)
{
return
(
isClassificationType
(
o
)
&&
((
AtlasClassificationType
)
o
).
getAllSuperTypes
().
contains
(
supertype
))||
(
isClassificationTypeDef
(
o
)
&&
((
AtlasClassificationDef
)
o
).
getSuperTypes
().
contains
(
supertype
))
||
(
isEntityType
(
o
)
&&
((
AtlasEntityType
)
o
).
getAllSuperTypes
().
contains
(
supertype
))
||
(
isEntityTypeDef
(
o
)
&&
((
AtlasEntityDef
)
o
).
getSuperTypes
().
contains
(
supertype
));
(
isEntityType
(
o
)
&&
((
AtlasEntityType
)
o
).
getAllSuperTypes
().
contains
(
supertype
));
}
};
}
...
...
@@ -134,27 +119,8 @@ public class FilterUtil {
// This shouldn't have happened
return
false
;
}
}
else
if
(
o
instanceof
AtlasBaseTypeDef
){
AtlasBaseTypeDef
typeDef
=
(
AtlasBaseTypeDef
)
o
;
switch
(
type
.
toUpperCase
())
{
case
"CLASS"
:
case
"ENTITY"
:
return
typeDef
.
getCategory
()
==
TypeCategory
.
ENTITY
;
case
"TRAIT"
:
case
"CLASSIFICATION"
:
return
typeDef
.
getCategory
()
==
TypeCategory
.
CLASSIFICATION
;
case
"STRUCT"
:
return
typeDef
.
getCategory
()
==
TypeCategory
.
STRUCT
;
case
"ENUM"
:
return
typeDef
.
getCategory
()
==
TypeCategory
.
ENUM
;
default
:
// This shouldn't have happened
return
false
;
}
}
else
{
return
false
;
}
return
false
;
}
};
}
...
...
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