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
a9aa5b0e
Commit
a9aa5b0e
authored
Jan 23, 2019
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3034: Perf enhancement to avoid unnecessary lookup when creating new relationships
parent
de7fe47a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
24 deletions
+12
-24
AtlasRelationshipStore.java
.../atlas/repository/store/graph/AtlasRelationshipStore.java
+4
-0
AtlasRelationshipStoreV2.java
...s/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+0
-0
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+8
-24
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
View file @
a9aa5b0e
...
...
@@ -59,6 +59,10 @@ public interface AtlasRelationshipStore {
AtlasEdge
getOrCreate
(
AtlasVertex
end1Vertex
,
AtlasVertex
end2Vertex
,
AtlasRelationship
relationship
)
throws
AtlasBaseException
;
AtlasEdge
getRelationship
(
AtlasVertex
end1Vertex
,
AtlasVertex
end2Vertex
,
AtlasRelationship
relationship
);
AtlasEdge
createRelationship
(
AtlasVertex
end1Vertex
,
AtlasVertex
end2Vertex
,
AtlasRelationship
relationship
)
throws
AtlasBaseException
;
/**
* Retrieve a relationship if it exists or creates a new relationship instance.
* @param relationship relationship instance definition
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
View file @
a9aa5b0e
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
a9aa5b0e
...
...
@@ -819,7 +819,6 @@ public class EntityGraphMapper {
AtlasType
type
=
typeRegistry
.
getType
(
AtlasGraphUtilsV2
.
getTypeName
(
entityVertex
));
AtlasRelationshipEdgeDirection
edgeDirection
=
ctx
.
getAttribute
().
getRelationshipEdgeDirection
();
String
edgeLabel
=
ctx
.
getAttribute
().
getRelationshipEdgeLabel
();
if
(
type
instanceof
AtlasEntityType
)
{
AtlasEntityType
entityType
=
(
AtlasEntityType
)
type
;
...
...
@@ -844,10 +843,17 @@ public class EntityGraphMapper {
fromVertex
=
entityVertex
;
toVertex
=
attributeVertex
;
}
boolean
relationshipExists
=
isRelationshipExists
(
fromVertex
,
toVertex
,
edgeLabel
);
ret
=
getOrCreateRelationship
(
fromVertex
,
toVertex
,
relationshipName
,
relationshipAttributes
);
boolean
isCreated
=
GraphHelper
.
getCreatedTime
(
ret
)
==
RequestContext
.
get
().
getRequestTime
();
if
(
isCreated
)
{
// if relationship did not exist before and new relationship was created
// record entity update on both relationship vertices
recordEntityUpdate
(
attributeVertex
);
}
// for import use the relationship guid provided
if
(
RequestContext
.
get
().
isImportInProgress
())
{
String
relationshipGuid
=
getRelationshipGuid
(
ctx
.
getValue
());
...
...
@@ -856,12 +862,6 @@ public class EntityGraphMapper {
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
RELATIONSHIP_GUID_PROPERTY_KEY
,
relationshipGuid
);
}
}
// if relationship did not exist before and new relationship was created
// record entity update on both relationship vertices
if
(!
relationshipExists
)
{
recordEntityUpdate
(
attributeVertex
);
}
}
}
else
{
// use legacy way to create/update edges
...
...
@@ -1851,22 +1851,6 @@ public class EntityGraphMapper {
return
relationshipStore
.
getOrCreate
(
end1Vertex
,
end2Vertex
,
new
AtlasRelationship
(
relationshipName
,
relationshipAttributes
));
}
private
boolean
isRelationshipExists
(
AtlasVertex
fromVertex
,
AtlasVertex
toVertex
,
String
edgeLabel
)
{
boolean
ret
=
false
;
Iterator
<
AtlasEdge
>
edges
=
graphHelper
.
getOutGoingEdgesByLabel
(
fromVertex
,
edgeLabel
);
while
(
edges
!=
null
&&
edges
.
hasNext
())
{
AtlasEdge
edge
=
edges
.
next
();
AtlasVertex
inVertex
=
edge
.
getInVertex
();
if
(
inVertex
!=
null
&&
StringUtils
.
equals
(
getIdFromVertex
(
inVertex
),
getIdFromVertex
(
toVertex
)))
{
ret
=
true
;
}
}
return
ret
;
}
private
void
recordEntityUpdate
(
AtlasVertex
vertex
)
throws
AtlasBaseException
{
RequestContext
req
=
RequestContext
.
get
();
...
...
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