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
be7c4cb6
Commit
be7c4cb6
authored
Jan 19, 2015
by
Venkatesh Seetharam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ISSUE-38 Map type to graph with type prefixes to enable search. Contributed by Venkatesh Seetharam
parent
1d1531ef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
84 deletions
+101
-84
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+0
-0
GraphUtils.java
...g/apache/hadoop/metadata/repository/graph/GraphUtils.java
+24
-33
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+77
-51
No files found.
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
be7c4cb6
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphUtils.java
View file @
be7c4cb6
...
@@ -23,10 +23,14 @@ import com.tinkerpop.blueprints.Edge;
...
@@ -23,10 +23,14 @@ import com.tinkerpop.blueprints.Edge;
import
com.tinkerpop.blueprints.Graph
;
import
com.tinkerpop.blueprints.Graph
;
import
com.tinkerpop.blueprints.GraphQuery
;
import
com.tinkerpop.blueprints.GraphQuery
;
import
com.tinkerpop.blueprints.Vertex
;
import
com.tinkerpop.blueprints.Vertex
;
import
org.apache.hadoop.metadata.ITypedInstance
;
import
org.apache.hadoop.metadata.ITypedReferenceableInstance
;
import
org.apache.hadoop.metadata.storage.Id
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.UUID
;
/**
/**
* Utility class for graph operations.
* Utility class for graph operations.
...
@@ -38,40 +42,26 @@ public final class GraphUtils {
...
@@ -38,40 +42,26 @@ public final class GraphUtils {
private
GraphUtils
()
{
private
GraphUtils
()
{
}
}
public
static
Edge
addEdge
(
Vertex
fromVertex
,
Vertex
toVertex
,
public
static
Vertex
createVertex
(
Graph
graph
,
String
vertexPropertyKey
,
String
edgeLabel
)
{
ITypedReferenceableInstance
typedInstance
)
{
return
addEdge
(
fromVertex
,
toVertex
,
vertexPropertyKey
,
edgeLabel
,
null
);
return
createVertex
(
graph
,
typedInstance
,
typedInstance
.
getId
()
);
}
}
public
static
Edge
addEdge
(
Vertex
fromVertex
,
Vertex
toVertex
,
public
static
Vertex
createVertex
(
Graph
graph
,
String
vertexPropertyKey
,
String
edgeLabel
,
String
timestamp
)
{
ITypedInstance
typedInstance
,
Edge
edge
=
findEdge
(
fromVertex
,
toVertex
,
vertexPropertyKey
,
edgeLabel
);
Id
typedInstanceId
)
{
final
Vertex
instanceVertex
=
graph
.
addVertex
(
null
);
// type
instanceVertex
.
setProperty
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
typedInstance
.
getTypeName
());
Edge
edgeToVertex
=
edge
!=
null
?
edge
:
fromVertex
.
addEdge
(
edgeLabel
,
toVertex
);
// id
if
(
timestamp
!=
null
)
{
final
String
guid
=
UUID
.
randomUUID
().
toString
();
edgeToVertex
.
setProperty
(
Constants
.
TIMESTAMP_PROPERTY_KEY
,
timestamp
);
instanceVertex
.
setProperty
(
Constants
.
GUID_PROPERTY_KEY
,
guid
);
}
return
edgeToVertex
;
}
public
static
Edge
findEdge
(
Vertex
fromVertex
,
Vertex
toVertex
,
// version
String
vertexPropertyKey
,
String
edgeLabel
)
{
instanceVertex
.
setProperty
(
Constants
.
VERSION_PROPERTY_KEY
,
typedInstanceId
.
version
);
return
findEdge
(
fromVertex
,
toVertex
.
getProperty
(
vertexPropertyKey
),
vertexPropertyKey
,
edgeLabel
);
}
public
static
Edge
findEdge
(
Vertex
fromVertex
,
Object
toVertexName
,
String
vertexPropertyKey
,
String
edgeLabel
)
{
Edge
edgeToFind
=
null
;
for
(
Edge
edge
:
fromVertex
.
getEdges
(
Direction
.
OUT
,
edgeLabel
))
{
if
(
edge
.
getVertex
(
Direction
.
IN
).
getProperty
(
vertexPropertyKey
).
equals
(
toVertexName
))
{
edgeToFind
=
edge
;
break
;
}
}
return
edgeToFind
;
return
instanceVertex
;
}
}
public
static
Vertex
findVertex
(
Graph
blueprintsGraph
,
public
static
Vertex
findVertex
(
Graph
blueprintsGraph
,
...
@@ -97,23 +87,23 @@ public final class GraphUtils {
...
@@ -97,23 +87,23 @@ public final class GraphUtils {
public
static
String
edgeString
(
final
Edge
edge
)
{
public
static
String
edgeString
(
final
Edge
edge
)
{
return
"e["
+
edge
.
getLabel
()
+
"], ["
return
"e["
+
edge
.
getLabel
()
+
"], ["
+
edge
.
getVertex
(
Direction
.
OUT
)
.
getProperty
(
"name"
)
+
edge
.
getVertex
(
Direction
.
OUT
)
+
" -> "
+
edge
.
getLabel
()
+
" -> "
+
" -> "
+
edge
.
getLabel
()
+
" -> "
+
edge
.
getVertex
(
Direction
.
IN
)
.
getProperty
(
"name"
)
+
edge
.
getVertex
(
Direction
.
IN
)
+
"]"
;
+
"]"
;
}
}
public
static
void
dumpToLog
(
final
Graph
graph
)
{
public
static
void
dumpToLog
(
final
Graph
graph
)
{
LOG
.
debug
(
"*******************Graph Dump****************************"
);
LOG
.
debug
(
"Vertices of {}"
,
graph
);
LOG
.
debug
(
"Vertices of {}"
,
graph
);
for
(
Vertex
vertex
:
graph
.
getVertices
())
{
for
(
Vertex
vertex
:
graph
.
getVertices
())
{
LOG
.
debug
(
vertexString
(
vertex
));
LOG
.
debug
(
vertexString
(
vertex
));
System
.
out
.
println
(
vertexString
(
vertex
));
}
}
LOG
.
debug
(
"Edges of {}"
,
graph
);
LOG
.
debug
(
"Edges of {}"
,
graph
);
for
(
Edge
edge
:
graph
.
getEdges
())
{
for
(
Edge
edge
:
graph
.
getEdges
())
{
LOG
.
debug
(
edgeString
(
edge
));
LOG
.
debug
(
edgeString
(
edge
));
System
.
out
.
println
(
edgeString
(
edge
));
}
}
LOG
.
debug
(
"*******************Graph Dump****************************"
);
}
}
}
}
\ No newline at end of file
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/EntityJerseyResourceIT.java
View file @
be7c4cb6
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