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
34d235f3
Commit
34d235f3
authored
Jan 17, 2017
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1471: avoid unnecessary overhead in debug log calls
parent
9c0c46db
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
125 additions
and
8 deletions
+125
-8
DeleteHandler.java
...java/org/apache/atlas/repository/graph/DeleteHandler.java
+27
-0
FullTextMapper.java
...ava/org/apache/atlas/repository/graph/FullTextMapper.java
+6
-0
GraphBackedMetadataRepository.java
...atlas/repository/graph/GraphBackedMetadataRepository.java
+25
-0
GraphBackedSearchIndexer.java
...ache/atlas/repository/graph/GraphBackedSearchIndexer.java
+15
-7
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+0
-0
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+52
-1
TypedInstanceToGraphMapper.java
...he/atlas/repository/graph/TypedInstanceToGraphMapper.java
+0
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java
View file @
34d235f3
...
@@ -79,7 +79,10 @@ public abstract class DeleteHandler {
...
@@ -79,7 +79,10 @@ public abstract class DeleteHandler {
String
guid
=
GraphHelper
.
getGuid
(
instanceVertex
);
String
guid
=
GraphHelper
.
getGuid
(
instanceVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
instanceVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
instanceVertex
);
if
(
requestContext
.
getDeletedEntityIds
().
contains
(
guid
)
||
state
==
Id
.
EntityState
.
DELETED
)
{
if
(
requestContext
.
getDeletedEntityIds
().
contains
(
guid
)
||
state
==
Id
.
EntityState
.
DELETED
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
guid
);
LOG
.
debug
(
"Skipping deletion of {} as it is already deleted"
,
guid
);
}
continue
;
continue
;
}
}
...
@@ -131,13 +134,19 @@ public abstract class DeleteHandler {
...
@@ -131,13 +134,19 @@ public abstract class DeleteHandler {
* @throws AtlasException
* @throws AtlasException
*/
*/
protected
void
deleteTypeVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
protected
void
deleteTypeVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting {}"
,
string
(
instanceVertex
));
LOG
.
debug
(
"Deleting {}"
,
string
(
instanceVertex
));
}
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
typeName
);
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
typeName
);
FieldMapping
fieldMapping
=
getFieldMapping
(
type
);
FieldMapping
fieldMapping
=
getFieldMapping
(
type
);
for
(
AttributeInfo
attributeInfo
:
fieldMapping
.
fields
.
values
())
{
for
(
AttributeInfo
attributeInfo
:
fieldMapping
.
fields
.
values
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting attribute {} for {}"
,
attributeInfo
.
name
,
string
(
instanceVertex
));
LOG
.
debug
(
"Deleting attribute {} for {}"
,
attributeInfo
.
name
,
string
(
instanceVertex
));
}
String
edgeLabel
=
GraphHelper
.
getEdgeLabel
(
type
,
attributeInfo
);
String
edgeLabel
=
GraphHelper
.
getEdgeLabel
(
type
,
attributeInfo
);
switch
(
attributeInfo
.
dataType
().
getTypeCategory
())
{
switch
(
attributeInfo
.
dataType
().
getTypeCategory
())
{
...
@@ -200,7 +209,10 @@ public abstract class DeleteHandler {
...
@@ -200,7 +209,10 @@ public abstract class DeleteHandler {
*/
*/
public
boolean
deleteEdgeReference
(
AtlasEdge
edge
,
DataTypes
.
TypeCategory
typeCategory
,
boolean
isComposite
,
public
boolean
deleteEdgeReference
(
AtlasEdge
edge
,
DataTypes
.
TypeCategory
typeCategory
,
boolean
isComposite
,
boolean
forceDeleteStructTrait
)
throws
AtlasException
{
boolean
forceDeleteStructTrait
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting {}"
,
string
(
edge
));
LOG
.
debug
(
"Deleting {}"
,
string
(
edge
));
}
boolean
forceDelete
=
boolean
forceDelete
=
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
)
&&
forceDeleteStructTrait
;
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
)
&&
forceDeleteStructTrait
;
if
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
if
(
typeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
typeCategory
==
DataTypes
.
TypeCategory
.
TRAIT
...
@@ -247,7 +259,9 @@ public abstract class DeleteHandler {
...
@@ -247,7 +259,9 @@ public abstract class DeleteHandler {
protected
void
deleteVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
protected
void
deleteVertex
(
AtlasVertex
instanceVertex
,
boolean
force
)
throws
AtlasException
{
//Update external references(incoming edges) to this vertex
//Update external references(incoming edges) to this vertex
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Setting the external references to {} to null(removing edges)"
,
string
(
instanceVertex
));
LOG
.
debug
(
"Setting the external references to {} to null(removing edges)"
,
string
(
instanceVertex
));
}
for
(
AtlasEdge
edge
:
(
Iterable
<
AtlasEdge
>)
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
IN
))
{
for
(
AtlasEdge
edge
:
(
Iterable
<
AtlasEdge
>)
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
IN
))
{
Id
.
EntityState
edgeState
=
GraphHelper
.
getState
(
edge
);
Id
.
EntityState
edgeState
=
GraphHelper
.
getState
(
edge
);
...
@@ -271,8 +285,11 @@ public abstract class DeleteHandler {
...
@@ -271,8 +285,11 @@ public abstract class DeleteHandler {
* @throws AtlasException
* @throws AtlasException
*/
*/
protected
void
deleteEdgeBetweenVertices
(
AtlasVertex
outVertex
,
AtlasVertex
inVertex
,
String
attributeName
)
throws
AtlasException
{
protected
void
deleteEdgeBetweenVertices
(
AtlasVertex
outVertex
,
AtlasVertex
inVertex
,
String
attributeName
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
LOG
.
debug
(
"Removing edge from {} to {} with attribute name {}"
,
string
(
outVertex
),
string
(
inVertex
),
attributeName
);
attributeName
);
}
String
typeName
=
GraphHelper
.
getTypeName
(
outVertex
);
String
typeName
=
GraphHelper
.
getTypeName
(
outVertex
);
String
outId
=
GraphHelper
.
getGuid
(
outVertex
);
String
outId
=
GraphHelper
.
getGuid
(
outVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
outVertex
);
Id
.
EntityState
state
=
GraphHelper
.
getState
(
outVertex
);
...
@@ -331,8 +348,11 @@ public abstract class DeleteHandler {
...
@@ -331,8 +348,11 @@ public abstract class DeleteHandler {
//if composite attribute, remove the reference as well. else, just remove the edge
//if composite attribute, remove the reference as well. else, just remove the edge
//for example, when table is deleted, process still references the table
//for example, when table is deleted, process still references the table
//but when column is deleted, table will not reference the deleted column
//but when column is deleted, table will not reference the deleted column
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge {} from the array attribute {}"
,
string
(
elementEdge
),
LOG
.
debug
(
"Removing edge {} from the array attribute {}"
,
string
(
elementEdge
),
attributeName
);
attributeName
);
}
elements
.
remove
(
elementEdge
.
getId
().
toString
());
elements
.
remove
(
elementEdge
.
getId
().
toString
());
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
elements
);
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
elements
);
break
;
break
;
...
@@ -367,8 +387,11 @@ public abstract class DeleteHandler {
...
@@ -367,8 +387,11 @@ public abstract class DeleteHandler {
if
(
shouldUpdateReverseAttribute
)
{
if
(
shouldUpdateReverseAttribute
)
{
//remove this key
//remove this key
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing edge {}, key {} from the map attribute {}"
,
string
(
mapEdge
),
key
,
LOG
.
debug
(
"Removing edge {}, key {} from the map attribute {}"
,
string
(
mapEdge
),
key
,
attributeName
);
attributeName
);
}
keys
.
remove
(
key
);
keys
.
remove
(
key
);
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
keys
);
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
keys
);
GraphHelper
.
setProperty
(
outVertex
,
keyPropertyName
,
null
);
GraphHelper
.
setProperty
(
outVertex
,
keyPropertyName
,
null
);
...
@@ -426,7 +449,11 @@ public abstract class DeleteHandler {
...
@@ -426,7 +449,11 @@ public abstract class DeleteHandler {
*/
*/
private
void
deleteAllTraits
(
AtlasVertex
instanceVertex
)
throws
AtlasException
{
private
void
deleteAllTraits
(
AtlasVertex
instanceVertex
)
throws
AtlasException
{
List
<
String
>
traitNames
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
List
<
String
>
traitNames
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting traits {} for {}"
,
traitNames
,
string
(
instanceVertex
));
LOG
.
debug
(
"Deleting traits {} for {}"
,
traitNames
,
string
(
instanceVertex
));
}
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
String
typeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
for
(
String
traitNameToBeDeleted
:
traitNames
)
{
for
(
String
traitNameToBeDeleted
:
traitNames
)
{
...
...
repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapper.java
View file @
34d235f3
...
@@ -56,13 +56,19 @@ public class FullTextMapper {
...
@@ -56,13 +56,19 @@ public class FullTextMapper {
ITypedReferenceableInstance
typedReference
;
ITypedReferenceableInstance
typedReference
;
if
(
instanceCache
.
containsKey
(
guid
))
{
if
(
instanceCache
.
containsKey
(
guid
))
{
typedReference
=
instanceCache
.
get
(
guid
);
typedReference
=
instanceCache
.
get
(
guid
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache hit: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
_getId
());
LOG
.
debug
(
"Cache hit: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
_getId
());
}
}
else
{
}
else
{
typedReference
=
typedReference
=
graphToTypedInstanceMapper
.
mapGraphToTypedInstance
(
guid
,
instanceVertex
);
graphToTypedInstanceMapper
.
mapGraphToTypedInstance
(
guid
,
instanceVertex
);
instanceCache
.
put
(
guid
,
typedReference
);
instanceCache
.
put
(
guid
,
typedReference
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Cache miss: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
getId
());
LOG
.
debug
(
"Cache miss: guid = {}, entityId = {}"
,
guid
,
typedReference
.
getId
().
getId
());
}
}
}
String
fullText
=
forInstance
(
typedReference
,
followReferences
);
String
fullText
=
forInstance
(
typedReference
,
followReferences
);
StringBuilder
fullTextBuilder
=
StringBuilder
fullTextBuilder
=
new
StringBuilder
(
typedReference
.
getTypeName
()).
append
(
FULL_TEXT_DELIMITER
).
append
(
fullText
);
new
StringBuilder
(
typedReference
.
getTypeName
()).
append
(
FULL_TEXT_DELIMITER
).
append
(
fullText
);
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
View file @
34d235f3
...
@@ -136,7 +136,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -136,7 +136,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@GraphTransaction
@GraphTransaction
public
List
<
String
>
createEntities
(
ITypedReferenceableInstance
...
entities
)
throws
RepositoryException
,
public
List
<
String
>
createEntities
(
ITypedReferenceableInstance
...
entities
)
throws
RepositoryException
,
EntityExistsException
{
EntityExistsException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"adding entities={}"
,
entities
);
LOG
.
debug
(
"adding entities={}"
,
entities
);
}
try
{
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
CREATE
,
entities
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
CREATE
,
entities
);
...
@@ -151,7 +154,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -151,7 +154,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
ITypedReferenceableInstance
getEntityDefinition
(
String
guid
)
throws
RepositoryException
,
EntityNotFoundException
{
public
ITypedReferenceableInstance
getEntityDefinition
(
String
guid
)
throws
RepositoryException
,
EntityNotFoundException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity with guid={}"
,
guid
);
LOG
.
debug
(
"Retrieving entity with guid={}"
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
@@ -166,7 +171,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -166,7 +171,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@GraphTransaction
@GraphTransaction
public
ITypedReferenceableInstance
getEntityDefinition
(
String
entityType
,
String
attribute
,
Object
value
)
public
ITypedReferenceableInstance
getEntityDefinition
(
String
entityType
,
String
attribute
,
Object
value
)
throws
AtlasException
{
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity with type={} and {}={}"
,
entityType
,
attribute
,
value
);
LOG
.
debug
(
"Retrieving entity with type={} and {}={}"
,
entityType
,
attribute
,
value
);
}
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
entityType
);
IDataType
type
=
typeSystem
.
getDataType
(
IDataType
.
class
,
entityType
);
String
propertyKey
=
getFieldNameInVertex
(
type
,
attribute
);
String
propertyKey
=
getFieldNameInVertex
(
type
,
attribute
);
AtlasVertex
instanceVertex
=
graphHelper
.
findVertex
(
propertyKey
,
value
,
AtlasVertex
instanceVertex
=
graphHelper
.
findVertex
(
propertyKey
,
value
,
...
@@ -180,7 +188,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -180,7 +188,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
List
<
String
>
getEntityList
(
String
entityType
)
throws
RepositoryException
{
public
List
<
String
>
getEntityList
(
String
entityType
)
throws
RepositoryException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving entity list for type={}"
,
entityType
);
LOG
.
debug
(
"Retrieving entity list for type={}"
,
entityType
);
}
AtlasGraphQuery
query
=
graph
.
query
().
has
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
entityType
);
AtlasGraphQuery
query
=
graph
.
query
().
has
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
entityType
);
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
if
(!
results
.
hasNext
())
{
if
(!
results
.
hasNext
())
{
...
@@ -206,7 +217,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -206,7 +217,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
List
<
String
>
getTraitNames
(
String
guid
)
throws
AtlasException
{
public
List
<
String
>
getTraitNames
(
String
guid
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Retrieving trait names for entity={}"
,
guid
);
LOG
.
debug
(
"Retrieving trait names for entity={}"
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
return
GraphHelper
.
getTraitNames
(
instanceVertex
);
return
GraphHelper
.
getTraitNames
(
instanceVertex
);
}
}
...
@@ -224,7 +238,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -224,7 +238,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
public
void
addTrait
(
String
guid
,
ITypedStruct
traitInstance
)
throws
RepositoryException
{
public
void
addTrait
(
String
guid
,
ITypedStruct
traitInstance
)
throws
RepositoryException
{
Preconditions
.
checkNotNull
(
traitInstance
,
"Trait instance cannot be null"
);
Preconditions
.
checkNotNull
(
traitInstance
,
"Trait instance cannot be null"
);
final
String
traitName
=
traitInstance
.
getTypeName
();
final
String
traitName
=
traitInstance
.
getTypeName
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Adding a new trait={} for entity={}"
,
traitName
,
guid
);
LOG
.
debug
(
"Adding a new trait={} for entity={}"
,
traitName
,
guid
);
}
try
{
try
{
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
@@ -260,7 +277,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -260,7 +277,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
void
deleteTrait
(
String
guid
,
String
traitNameToBeDeleted
)
throws
TraitNotFoundException
,
EntityNotFoundException
,
RepositoryException
{
public
void
deleteTrait
(
String
guid
,
String
traitNameToBeDeleted
)
throws
TraitNotFoundException
,
EntityNotFoundException
,
RepositoryException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Deleting trait={} from entity={}"
,
traitNameToBeDeleted
,
guid
);
LOG
.
debug
(
"Deleting trait={} from entity={}"
,
traitNameToBeDeleted
,
guid
);
}
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
AtlasVertex
instanceVertex
=
graphHelper
.
getVertexForGUID
(
guid
);
...
@@ -303,7 +322,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -303,7 +322,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
AtlasClient
.
EntityResult
updateEntities
(
ITypedReferenceableInstance
...
entitiesUpdated
)
throws
RepositoryException
{
public
AtlasClient
.
EntityResult
updateEntities
(
ITypedReferenceableInstance
...
entitiesUpdated
)
throws
RepositoryException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"updating entity {}"
,
entitiesUpdated
);
LOG
.
debug
(
"updating entity {}"
,
entitiesUpdated
);
}
try
{
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_FULL
,
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_FULL
,
...
@@ -319,7 +341,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -319,7 +341,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@Override
@Override
@GraphTransaction
@GraphTransaction
public
AtlasClient
.
EntityResult
updatePartial
(
ITypedReferenceableInstance
entity
)
throws
RepositoryException
{
public
AtlasClient
.
EntityResult
updatePartial
(
ITypedReferenceableInstance
entity
)
throws
RepositoryException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"updating entity {}"
,
entity
);
LOG
.
debug
(
"updating entity {}"
,
entity
);
}
try
{
try
{
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
TypedInstanceToGraphMapper
instanceToGraphMapper
=
new
TypedInstanceToGraphMapper
(
graphToInstanceMapper
,
deleteHandler
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_PARTIAL
,
entity
);
instanceToGraphMapper
.
mapTypedInstanceToGraph
(
TypedInstanceToGraphMapper
.
Operation
.
UPDATE_PARTIAL
,
entity
);
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
View file @
34d235f3
...
@@ -233,7 +233,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
...
@@ -233,7 +233,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
AtlasGraphManagement
management
=
provider
.
get
().
getManagementSystem
();
AtlasGraphManagement
management
=
provider
.
get
().
getManagementSystem
();
for
(
IDataType
dataType
:
dataTypes
)
{
for
(
IDataType
dataType
:
dataTypes
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating indexes for type name={}, definition={}"
,
dataType
.
getName
(),
dataType
.
getClass
());
LOG
.
debug
(
"Creating indexes for type name={}, definition={}"
,
dataType
.
getName
(),
dataType
.
getClass
());
}
try
{
try
{
addIndexForType
(
management
,
dataType
);
addIndexForType
(
management
,
dataType
);
LOG
.
info
(
"Index creation for type {} complete"
,
dataType
.
getName
());
LOG
.
info
(
"Index creation for type {} complete"
,
dataType
.
getName
());
...
@@ -506,17 +509,17 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
...
@@ -506,17 +509,17 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
AtlasPropertyKey
propertyKey
,
boolean
enforceUniqueness
)
{
AtlasPropertyKey
propertyKey
,
boolean
enforceUniqueness
)
{
String
propertyName
=
propertyKey
.
getName
();
String
propertyName
=
propertyKey
.
getName
();
LOG
.
debug
(
"Creating composite index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating composite index for property {} of type {}; isUnique={} "
,
propertyName
,
propertyClass
.
getName
(),
enforceUniqueness
);
}
AtlasGraphIndex
existingIndex
=
management
.
getGraphIndex
(
propertyName
);
AtlasGraphIndex
existingIndex
=
management
.
getGraphIndex
(
propertyName
);
if
(
existingIndex
==
null
)
{
if
(
existingIndex
==
null
)
{
if
(
enforceUniqueness
)
{
LOG
.
debug
(
"Enabling unique index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
management
.
createExactMatchIndex
(
propertyName
,
enforceUniqueness
,
Collections
.
singletonList
(
propertyKey
));
management
.
createExactMatchIndex
(
propertyName
,
enforceUniqueness
,
Collections
.
singletonList
(
propertyKey
));
}
}
LOG
.
info
(
"Created composite index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
LOG
.
info
(
"Created composite index for property {} of type {}; isUnique={} "
,
propertyName
,
propertyClass
.
getName
(),
enforceUniqueness
);
}
}
...
@@ -536,8 +539,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
...
@@ -536,8 +539,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
Class
propertyClass
,
AtlasPropertyKey
propertyKey
,
final
String
systemPropertyKey
,
Class
propertyClass
,
AtlasPropertyKey
propertyKey
,
final
String
systemPropertyKey
,
AtlasCardinality
cardinality
)
{
AtlasCardinality
cardinality
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating composite index for property {} of type {} and {}"
,
propertyKey
.
getName
(),
propertyClass
.
getName
(),
LOG
.
debug
(
"Creating composite index for property {} of type {} and {}"
,
propertyKey
.
getName
(),
propertyClass
.
getName
(),
systemPropertyKey
);
systemPropertyKey
);
}
AtlasPropertyKey
typePropertyKey
=
management
.
getPropertyKey
(
systemPropertyKey
);
AtlasPropertyKey
typePropertyKey
=
management
.
getPropertyKey
(
systemPropertyKey
);
if
(
typePropertyKey
==
null
)
{
if
(
typePropertyKey
==
null
)
{
...
@@ -562,9 +567,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
...
@@ -562,9 +567,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateCh
private
void
updateVertexIndex
(
AtlasGraphManagement
management
,
String
propertyName
,
Class
propertyClass
,
private
void
updateVertexIndex
(
AtlasGraphManagement
management
,
String
propertyName
,
Class
propertyClass
,
AtlasCardinality
cardinality
,
AtlasPropertyKey
propertyKey
)
{
AtlasCardinality
cardinality
,
AtlasPropertyKey
propertyKey
)
{
if
(
checkIfVertexIndexApplicable
(
propertyClass
,
cardinality
))
{
if
(
checkIfVertexIndexApplicable
(
propertyClass
,
cardinality
))
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
// Use backing index
// Use backing index
management
.
addVertexIndexKey
(
Constants
.
VERTEX_INDEX
,
propertyKey
);
management
.
addVertexIndexKey
(
Constants
.
VERTEX_INDEX
,
propertyKey
);
LOG
.
debug
(
"Creating backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
LOG
.
info
(
"Created backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
LOG
.
info
(
"Created backing index for property {} of type {} "
,
propertyName
,
propertyClass
.
getName
());
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
34d235f3
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
34d235f3
...
@@ -70,7 +70,10 @@ public final class GraphToTypedInstanceMapper {
...
@@ -70,7 +70,10 @@ public final class GraphToTypedInstanceMapper {
public
ITypedReferenceableInstance
mapGraphToTypedInstance
(
String
guid
,
AtlasVertex
instanceVertex
)
public
ITypedReferenceableInstance
mapGraphToTypedInstance
(
String
guid
,
AtlasVertex
instanceVertex
)
throws
AtlasException
{
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Mapping graph root vertex {} to typed instance for guid {}"
,
instanceVertex
,
guid
);
LOG
.
debug
(
"Mapping graph root vertex {} to typed instance for guid {}"
,
instanceVertex
,
guid
);
}
String
typeName
=
GraphHelper
.
getSingleValuedProperty
(
instanceVertex
,
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
String
typeName
=
GraphHelper
.
getSingleValuedProperty
(
instanceVertex
,
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
List
<
String
>
traits
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
List
<
String
>
traits
=
GraphHelper
.
getTraitNames
(
instanceVertex
);
String
state
=
GraphHelper
.
getStateAsString
(
instanceVertex
);
String
state
=
GraphHelper
.
getStateAsString
(
instanceVertex
);
...
@@ -80,11 +83,16 @@ public final class GraphToTypedInstanceMapper {
...
@@ -80,11 +83,16 @@ public final class GraphToTypedInstanceMapper {
Date
modifiedTime
=
new
Date
(
GraphHelper
.
getModifiedTime
(
instanceVertex
));
Date
modifiedTime
=
new
Date
(
GraphHelper
.
getModifiedTime
(
instanceVertex
));
AtlasSystemAttributes
systemAttributes
=
new
AtlasSystemAttributes
(
createdBy
,
modifiedBy
,
createdTime
,
modifiedTime
);
AtlasSystemAttributes
systemAttributes
=
new
AtlasSystemAttributes
(
createdBy
,
modifiedBy
,
createdTime
,
modifiedTime
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found createdBy : {} modifiedBy : {} createdTime: {} modifedTime: {}"
,
createdBy
,
modifiedBy
,
createdTime
,
modifiedTime
);
LOG
.
debug
(
"Found createdBy : {} modifiedBy : {} createdTime: {} modifedTime: {}"
,
createdBy
,
modifiedBy
,
createdTime
,
modifiedTime
);
}
Id
id
=
new
Id
(
guid
,
Integer
.
parseInt
(
String
.
valueOf
(
GraphHelper
.
getProperty
(
instanceVertex
,
Constants
.
VERSION_PROPERTY_KEY
))),
Id
id
=
new
Id
(
guid
,
Integer
.
parseInt
(
String
.
valueOf
(
GraphHelper
.
getProperty
(
instanceVertex
,
Constants
.
VERSION_PROPERTY_KEY
))),
typeName
,
state
);
typeName
,
state
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Created id {} for instance type {}"
,
id
,
typeName
);
LOG
.
debug
(
"Created id {} for instance type {}"
,
id
,
typeName
);
}
ClassType
classType
=
typeSystem
.
getDataType
(
ClassType
.
class
,
typeName
);
ClassType
classType
=
typeSystem
.
getDataType
(
ClassType
.
class
,
typeName
);
ITypedReferenceableInstance
typedInstance
=
ITypedReferenceableInstance
typedInstance
=
...
@@ -100,7 +108,10 @@ public final class GraphToTypedInstanceMapper {
...
@@ -100,7 +108,10 @@ public final class GraphToTypedInstanceMapper {
private
void
mapVertexToInstanceTraits
(
AtlasVertex
instanceVertex
,
ITypedReferenceableInstance
typedInstance
,
private
void
mapVertexToInstanceTraits
(
AtlasVertex
instanceVertex
,
ITypedReferenceableInstance
typedInstance
,
List
<
String
>
traits
)
throws
AtlasException
{
List
<
String
>
traits
)
throws
AtlasException
{
for
(
String
traitName
:
traits
)
{
for
(
String
traitName
:
traits
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"mapping trait {} to instance"
,
traitName
);
LOG
.
debug
(
"mapping trait {} to instance"
,
traitName
);
}
TraitType
traitType
=
typeSystem
.
getDataType
(
TraitType
.
class
,
traitName
);
TraitType
traitType
=
typeSystem
.
getDataType
(
TraitType
.
class
,
traitName
);
mapVertexToTraitInstance
(
instanceVertex
,
typedInstance
,
traitName
,
traitType
);
mapVertexToTraitInstance
(
instanceVertex
,
typedInstance
,
traitName
,
traitType
);
}
}
...
@@ -110,8 +121,11 @@ public final class GraphToTypedInstanceMapper {
...
@@ -110,8 +121,11 @@ public final class GraphToTypedInstanceMapper {
public
void
mapVertexToInstance
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
public
void
mapVertexToInstance
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
Map
<
String
,
AttributeInfo
>
fields
)
throws
AtlasException
{
Map
<
String
,
AttributeInfo
>
fields
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Mapping vertex {} to instance {} for fields"
,
instanceVertex
,
typedInstance
.
getTypeName
(),
LOG
.
debug
(
"Mapping vertex {} to instance {} for fields"
,
instanceVertex
,
typedInstance
.
getTypeName
(),
fields
);
fields
);
}
for
(
AttributeInfo
attributeInfo
:
fields
.
values
())
{
for
(
AttributeInfo
attributeInfo
:
fields
.
values
())
{
mapVertexToAttribute
(
instanceVertex
,
typedInstance
,
attributeInfo
);
mapVertexToAttribute
(
instanceVertex
,
typedInstance
,
attributeInfo
);
}
}
...
@@ -119,7 +133,11 @@ public final class GraphToTypedInstanceMapper {
...
@@ -119,7 +133,11 @@ public final class GraphToTypedInstanceMapper {
private
void
mapVertexToAttribute
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
private
void
mapVertexToAttribute
(
AtlasVertex
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
)
throws
AtlasException
{
AttributeInfo
attributeInfo
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Mapping attributeInfo {}"
,
attributeInfo
.
name
);
LOG
.
debug
(
"Mapping attributeInfo {}"
,
attributeInfo
.
name
);
}
final
IDataType
dataType
=
attributeInfo
.
dataType
();
final
IDataType
dataType
=
attributeInfo
.
dataType
();
final
String
vertexPropertyName
=
GraphHelper
.
getQualifiedFieldName
(
typedInstance
,
attributeInfo
);
final
String
vertexPropertyName
=
GraphHelper
.
getQualifiedFieldName
(
typedInstance
,
attributeInfo
);
String
relationshipLabel
=
GraphHelper
.
getEdgeLabel
(
typedInstance
,
attributeInfo
);
String
relationshipLabel
=
GraphHelper
.
getEdgeLabel
(
typedInstance
,
attributeInfo
);
...
@@ -172,7 +190,9 @@ public final class GraphToTypedInstanceMapper {
...
@@ -172,7 +190,9 @@ public final class GraphToTypedInstanceMapper {
private
Object
mapVertexToClassReference
(
AtlasVertex
instanceVertex
,
AttributeInfo
attributeInfo
,
private
Object
mapVertexToClassReference
(
AtlasVertex
instanceVertex
,
AttributeInfo
attributeInfo
,
String
relationshipLabel
,
IDataType
dataType
,
AtlasEdge
optionalEdge
)
throws
AtlasException
{
String
relationshipLabel
,
IDataType
dataType
,
AtlasEdge
optionalEdge
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
}
AtlasEdge
edge
=
null
;
AtlasEdge
edge
=
null
;
if
(
optionalEdge
==
null
)
{
if
(
optionalEdge
==
null
)
{
...
@@ -184,7 +204,11 @@ public final class GraphToTypedInstanceMapper {
...
@@ -184,7 +204,11 @@ public final class GraphToTypedInstanceMapper {
if
(
GraphHelper
.
elementExists
(
edge
))
{
if
(
GraphHelper
.
elementExists
(
edge
))
{
final
AtlasVertex
referenceVertex
=
edge
.
getInVertex
();
final
AtlasVertex
referenceVertex
=
edge
.
getInVertex
();
final
String
guid
=
GraphHelper
.
getSingleValuedProperty
(
referenceVertex
,
Constants
.
GUID_PROPERTY_KEY
,
String
.
class
);
final
String
guid
=
GraphHelper
.
getSingleValuedProperty
(
referenceVertex
,
Constants
.
GUID_PROPERTY_KEY
,
String
.
class
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found vertex {} for label {} with guid {}"
,
referenceVertex
,
relationshipLabel
,
guid
);
LOG
.
debug
(
"Found vertex {} for label {} with guid {}"
,
referenceVertex
,
relationshipLabel
,
guid
);
}
if
(
attributeInfo
.
isComposite
)
{
if
(
attributeInfo
.
isComposite
)
{
//Also, when you retrieve a type's instance, you get the complete object graph of the composites
//Also, when you retrieve a type's instance, you get the complete object graph of the composites
LOG
.
debug
(
"Found composite, mapping vertex to instance"
);
LOG
.
debug
(
"Found composite, mapping vertex to instance"
);
...
@@ -194,7 +218,11 @@ public final class GraphToTypedInstanceMapper {
...
@@ -194,7 +218,11 @@ public final class GraphToTypedInstanceMapper {
Id
referenceId
=
Id
referenceId
=
new
Id
(
guid
,
GraphHelper
.
getSingleValuedProperty
(
referenceVertex
,
Constants
.
VERSION_PROPERTY_KEY
,
Integer
.
class
),
new
Id
(
guid
,
GraphHelper
.
getSingleValuedProperty
(
referenceVertex
,
Constants
.
VERSION_PROPERTY_KEY
,
Integer
.
class
),
dataType
.
getName
(),
state
);
dataType
.
getName
(),
state
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found non-composite, adding id {} "
,
referenceId
);
LOG
.
debug
(
"Found non-composite, adding id {} "
,
referenceId
);
}
return
referenceId
;
return
referenceId
;
}
}
}
}
...
@@ -205,7 +233,9 @@ public final class GraphToTypedInstanceMapper {
...
@@ -205,7 +233,9 @@ public final class GraphToTypedInstanceMapper {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
void
mapVertexToArrayInstance
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
private
void
mapVertexToArrayInstance
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
,
String
propertyName
)
throws
AtlasException
{
AttributeInfo
attributeInfo
,
String
propertyName
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
}
final
DataTypes
.
ArrayType
arrayType
=
(
DataTypes
.
ArrayType
)
attributeInfo
.
dataType
();
final
DataTypes
.
ArrayType
arrayType
=
(
DataTypes
.
ArrayType
)
attributeInfo
.
dataType
();
final
IDataType
elementType
=
arrayType
.
getElemType
();
final
IDataType
elementType
=
arrayType
.
getElemType
();
...
@@ -257,7 +287,10 @@ public final class GraphToTypedInstanceMapper {
...
@@ -257,7 +287,10 @@ public final class GraphToTypedInstanceMapper {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
void
mapVertexToMapInstance
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
private
void
mapVertexToMapInstance
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
,
final
String
propertyName
)
throws
AtlasException
{
AttributeInfo
attributeInfo
,
final
String
propertyName
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
}
List
<
String
>
keys
=
GraphHelper
.
getListProperty
(
instanceVertex
,
propertyName
);
List
<
String
>
keys
=
GraphHelper
.
getListProperty
(
instanceVertex
,
propertyName
);
if
(
keys
==
null
||
keys
.
size
()
==
0
)
{
if
(
keys
==
null
||
keys
.
size
()
==
0
)
{
return
;
return
;
...
@@ -283,7 +316,10 @@ public final class GraphToTypedInstanceMapper {
...
@@ -283,7 +316,10 @@ public final class GraphToTypedInstanceMapper {
private
ITypedStruct
mapVertexToStructInstance
(
AtlasVertex
instanceVertex
,
StructType
structType
,
private
ITypedStruct
mapVertexToStructInstance
(
AtlasVertex
instanceVertex
,
StructType
structType
,
String
relationshipLabel
,
AtlasEdge
optionalEdge
)
throws
AtlasException
{
String
relationshipLabel
,
AtlasEdge
optionalEdge
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"mapping {} to struct {}"
,
string
(
instanceVertex
),
relationshipLabel
);
LOG
.
debug
(
"mapping {} to struct {}"
,
string
(
instanceVertex
),
relationshipLabel
);
}
ITypedStruct
structInstance
=
null
;
ITypedStruct
structInstance
=
null
;
AtlasEdge
edge
;
AtlasEdge
edge
;
...
@@ -296,10 +332,12 @@ public final class GraphToTypedInstanceMapper {
...
@@ -296,10 +332,12 @@ public final class GraphToTypedInstanceMapper {
if
(
GraphHelper
.
elementExists
(
edge
))
{
if
(
GraphHelper
.
elementExists
(
edge
))
{
structInstance
=
structType
.
createInstance
();
structInstance
=
structType
.
createInstance
();
AtlasVertex
structInstanceVertex
=
edge
.
getInVertex
();
AtlasVertex
structInstanceVertex
=
edge
.
getInVertex
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found struct instance {}, mapping to instance {} "
,
string
(
structInstanceVertex
),
LOG
.
debug
(
"Found struct instance {}, mapping to instance {} "
,
string
(
structInstanceVertex
),
structInstance
.
getTypeName
());
structInstance
.
getTypeName
());
mapVertexToInstance
(
structInstanceVertex
,
structInstance
,
structType
.
fieldMapping
().
fields
);
}
mapVertexToInstance
(
structInstanceVertex
,
structInstance
,
structType
.
fieldMapping
().
fields
);
}
}
return
structInstance
;
return
structInstance
;
}
}
...
@@ -314,12 +352,19 @@ public final class GraphToTypedInstanceMapper {
...
@@ -314,12 +352,19 @@ public final class GraphToTypedInstanceMapper {
private
void
mapVertexToTraitInstance
(
AtlasVertex
<?,?>
instanceVertex
,
String
typedInstanceTypeName
,
String
traitName
,
private
void
mapVertexToTraitInstance
(
AtlasVertex
<?,?>
instanceVertex
,
String
typedInstanceTypeName
,
String
traitName
,
TraitType
traitType
,
ITypedStruct
traitInstance
)
throws
AtlasException
{
TraitType
traitType
,
ITypedStruct
traitInstance
)
throws
AtlasException
{
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
typedInstanceTypeName
,
traitName
);
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
typedInstanceTypeName
,
traitName
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
}
for
(
AtlasEdge
<?,?>
edge
:
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
OUT
,
relationshipLabel
))
{
for
(
AtlasEdge
<?,?>
edge
:
instanceVertex
.
getEdges
(
AtlasEdgeDirection
.
OUT
,
relationshipLabel
))
{
final
AtlasVertex
<?,?>
traitInstanceVertex
=
edge
.
getInVertex
();
final
AtlasVertex
<?,?>
traitInstanceVertex
=
edge
.
getInVertex
();
if
(
traitInstanceVertex
!=
null
)
{
if
(
traitInstanceVertex
!=
null
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found trait instance vertex {}, mapping to instance {} "
,
traitInstanceVertex
,
LOG
.
debug
(
"Found trait instance vertex {}, mapping to instance {} "
,
traitInstanceVertex
,
traitInstance
.
getTypeName
());
traitInstance
.
getTypeName
());
}
mapVertexToInstance
(
traitInstanceVertex
,
traitInstance
,
traitType
.
fieldMapping
().
fields
);
mapVertexToInstance
(
traitInstanceVertex
,
traitInstance
,
traitType
.
fieldMapping
().
fields
);
break
;
break
;
}
}
...
@@ -328,7 +373,10 @@ public final class GraphToTypedInstanceMapper {
...
@@ -328,7 +373,10 @@ public final class GraphToTypedInstanceMapper {
private
void
mapVertexToPrimitive
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
private
void
mapVertexToPrimitive
(
AtlasVertex
<?,?>
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
)
throws
AtlasException
{
AttributeInfo
attributeInfo
)
throws
AtlasException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Adding primitive {} from vertex {}"
,
attributeInfo
,
instanceVertex
);
LOG
.
debug
(
"Adding primitive {} from vertex {}"
,
attributeInfo
,
instanceVertex
);
}
final
String
vertexPropertyName
=
GraphHelper
.
getQualifiedFieldName
(
typedInstance
,
attributeInfo
);
final
String
vertexPropertyName
=
GraphHelper
.
getQualifiedFieldName
(
typedInstance
,
attributeInfo
);
if
(
GraphHelper
.
getSingleValuedProperty
(
instanceVertex
,
vertexPropertyName
,
Object
.
class
)
==
null
)
{
if
(
GraphHelper
.
getSingleValuedProperty
(
instanceVertex
,
vertexPropertyName
,
Object
.
class
)
==
null
)
{
return
;
return
;
...
@@ -369,8 +417,11 @@ public final class GraphToTypedInstanceMapper {
...
@@ -369,8 +417,11 @@ public final class GraphToTypedInstanceMapper {
if
(
referredVertex
!=
null
)
{
if
(
referredVertex
!=
null
)
{
switch
(
referredType
.
getTypeCategory
())
{
switch
(
referredType
.
getTypeCategory
())
{
case
STRUCT:
case
STRUCT:
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found struct instance vertex {}, mapping to instance {} "
,
referredVertex
,
LOG
.
debug
(
"Found struct instance vertex {}, mapping to instance {} "
,
referredVertex
,
referredType
.
getName
());
referredType
.
getName
());
}
StructType
structType
=
(
StructType
)
referredType
;
StructType
structType
=
(
StructType
)
referredType
;
ITypedStruct
instance
=
structType
.
createInstance
();
ITypedStruct
instance
=
structType
.
createInstance
();
Map
<
String
,
AttributeInfo
>
fields
=
structType
.
fieldMapping
().
fields
;
Map
<
String
,
AttributeInfo
>
fields
=
structType
.
fieldMapping
().
fields
;
...
...
repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
View file @
34d235f3
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