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
23aea76f
Commit
23aea76f
authored
May 04, 2020
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3762: Improve edge creation using genuine iterator. Part 2
parent
f4672292
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
24 deletions
+23
-24
AtlasGraph.java
.../java/org/apache/atlas/repository/graphdb/AtlasGraph.java
+9
-0
AtlasJanusGraph.java
...pache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
+11
-0
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+2
-0
AtlasRelationshipStoreV2.java
...s/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+1
-24
No files found.
graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraph.java
View file @
23aea76f
...
...
@@ -48,6 +48,15 @@ public interface AtlasGraph<V, E> {
AtlasEdge
<
V
,
E
>
addEdge
(
AtlasVertex
<
V
,
E
>
outVertex
,
AtlasVertex
<
V
,
E
>
inVertex
,
String
label
);
/**
* Fetch edges between two vertices using relationshipLabel
* @param fromVertex
* @param toVertex
* @param relationshipLabel
* @return
*/
AtlasEdge
<
V
,
E
>
getEdgeBetweenVertices
(
AtlasVertex
fromVertex
,
AtlasVertex
toVertex
,
String
relationshipLabel
);
/**
* Adds a vertex to the graph.
*
* @return
...
...
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
View file @
23aea76f
...
...
@@ -172,6 +172,17 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
}
@Override
public
AtlasEdge
getEdgeBetweenVertices
(
AtlasVertex
fromVertex
,
AtlasVertex
toVertex
,
String
edgeLabel
)
{
GraphTraversal
gt
=
V
(
fromVertex
.
getId
()).
outE
(
edgeLabel
).
where
(
__
.
otherV
().
hasId
(
toVertex
.
getId
()));
Object
o
=
gt
.
hasNext
()
?
gt
.
next
()
:
null
;
if
(
o
==
null
)
{
return
null
;
}
return
GraphDbObjectFactory
.
createEdge
(
this
,
(
Edge
)
o
);
}
@Override
public
AtlasEdge
<
AtlasJanusVertex
,
AtlasJanusEdge
>
getEdge
(
String
edgeId
)
{
Iterator
<
Edge
>
it
=
getGraph
().
edges
(
edgeId
);
Edge
e
=
getSingleElement
(
it
,
edgeId
);
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
23aea76f
...
...
@@ -739,6 +739,7 @@ public final class GraphHelper {
public
static
List
<
AtlasVertex
>
getPropagationEnabledClassificationVertices
(
AtlasVertex
entityVertex
)
{
List
<
AtlasVertex
>
ret
=
new
ArrayList
<>();
if
(
entityVertex
.
hasEdges
(
AtlasEdgeDirection
.
OUT
,
CLASSIFICATION_LABEL
))
{
Iterable
edges
=
entityVertex
.
query
().
direction
(
AtlasEdgeDirection
.
OUT
).
label
(
CLASSIFICATION_LABEL
).
edges
();
if
(
edges
!=
null
)
{
...
...
@@ -756,6 +757,7 @@ public final class GraphHelper {
}
}
}
}
return
ret
;
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
View file @
23aea76f
...
...
@@ -784,36 +784,13 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
AtlasEdge
ret
=
null
;
if
(
toVertex
.
hasEdges
(
AtlasEdgeDirection
.
IN
,
relationshipLabel
)
&&
fromVertex
.
hasEdges
(
AtlasEdgeDirection
.
OUT
,
relationshipLabel
))
{
long
fromVertexOutgoingEdgeCount
=
graphHelper
.
getOutGoingEdgesCountByLabel
(
fromVertex
,
relationshipLabel
);
long
toVertexIncomingEdgeCount
=
graphHelper
.
getInComingEdgesCountByLabel
(
toVertex
,
relationshipLabel
);
if
(
toVertexIncomingEdgeCount
<
fromVertexOutgoingEdgeCount
)
{
Iterator
<
AtlasEdge
>
edgesIteratorIn
=
graphHelper
.
getIncomingEdgesByLabel
(
toVertex
,
relationshipLabel
);
ret
=
getActiveEdgeFromList
(
edgesIteratorIn
,
fromVertex
.
getId
(),
e
->
e
.
getOutVertex
().
getId
());
}
else
{
Iterator
<
AtlasEdge
>
edgesIteratorOut
=
graphHelper
.
getOutGoingEdgesByLabel
(
fromVertex
,
relationshipLabel
);
ret
=
getActiveEdgeFromList
(
edgesIteratorOut
,
toVertex
.
getId
(),
e
->
e
.
getInVertex
().
getId
());
}
ret
=
graph
.
getEdgeBetweenVertices
(
fromVertex
,
toVertex
,
relationshipLabel
);
}
RequestContext
.
get
().
endMetricRecord
(
metric
);
return
ret
;
}
private
AtlasEdge
getActiveEdgeFromList
(
Iterator
<
AtlasEdge
>
edgesIterator
,
Object
vertexIdToCompare
,
Function
<
AtlasEdge
,
Object
>
edgeIdFn
)
{
while
(
edgesIterator
!=
null
&&
edgesIterator
.
hasNext
())
{
AtlasEdge
edge
=
edgesIterator
.
next
();
if
(
edge
!=
null
)
{
Status
status
=
graphHelper
.
getStatus
(
edge
);
if
((
status
==
null
||
status
==
ACTIVE
)
&&
edgeIdFn
.
apply
(
edge
).
equals
(
vertexIdToCompare
))
{
return
edge
;
}
}
}
return
null
;
}
private
Long
getRelationshipVersion
(
AtlasRelationship
relationship
)
{
Long
ret
=
relationship
!=
null
?
relationship
.
getVersion
()
:
null
;
...
...
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