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
305d16a1
Commit
305d16a1
authored
9 years ago
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend GraphPersistenceStrategy to expose IdAttrName and materialization of internal Id StructType
parent
543f3a72
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
2 deletions
+60
-2
DefaultGraphPersistenceStrategy.java
...data/discovery/graph/DefaultGraphPersistenceStrategy.java
+21
-2
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+4
-0
GraphPersistenceStrategies.scala
...he/hadoop/metadata/query/GraphPersistenceStrategies.scala
+23
-0
TypeUtils.scala
...in/scala/org/apache/hadoop/metadata/query/TypeUtils.scala
+12
-0
No files found.
repository/src/main/java/org/apache/hadoop/metadata/discovery/graph/DefaultGraphPersistenceStrategy.java
View file @
305d16a1
...
...
@@ -108,8 +108,17 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi
TitanVertex
structVertex
=
(
TitanVertex
)
value
;
StructType
structType
=
(
StructType
)
dataType
;
ITypedStruct
structInstance
=
structType
.
createInstance
();
metadataRepository
.
getGraphToInstanceMapper
().
mapVertexToInstance
(
structVertex
,
structInstance
,
structType
.
fieldMapping
().
fields
);
if
(
dataType
.
getName
()
==
TypeUtils
.
INSTANCE_ID_TYP
().
getName
())
{
structInstance
.
set
(
TypeUtils
.
INSTANCE_ID_TYP_TYPENAME_ATTRNAME
(),
structVertex
.
getProperty
(
typeAttributeName
()));
structInstance
.
set
(
TypeUtils
.
INSTANCE_ID_TYP_ID_ATTRNAME
(),
structVertex
.
getProperty
(
idAttributeName
()));
}
else
{
metadataRepository
.
getGraphToInstanceMapper
().
mapVertexToInstance
(
structVertex
,
structInstance
,
structType
.
fieldMapping
().
fields
);
}
return
dataType
.
convert
(
structInstance
,
Multiplicity
.
OPTIONAL
);
case
TRAIT:
...
...
@@ -180,4 +189,14 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi
public
String
loopObjectExpression
(
IDataType
<?>
dataType
)
{
return
"{it.object."
+
typeAttributeName
()
+
" == '"
+
dataType
.
getName
()
+
"'}"
;
}
@Override
public
String
instanceToTraitEdgeDirection
()
{
return
"out"
;
}
@Override
public
String
traitToInstanceEdgeDirection
()
{
return
"in"
;
}
@Override
public
String
idAttributeName
()
{
return
metadataRepository
.
getIdAttributeName
();
}
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
305d16a1
...
...
@@ -96,6 +96,10 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
return
Constants
.
ENTITY_TYPE_PROPERTY_KEY
;
}
public
String
getIdAttributeName
()
{
return
Constants
.
GUID_PROPERTY_KEY
;
}
@Override
public
String
getTraitLabel
(
IDataType
<?>
dataType
,
String
traitName
)
{
return
dataType
.
getName
()
+
"."
+
traitName
;
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/scala/org/apache/hadoop/metadata/query/GraphPersistenceStrategies.scala
View file @
305d16a1
...
...
@@ -45,12 +45,24 @@ trait GraphPersistenceStrategies {
def
typeAttributeName
:
String
/**
* Name of attribute used to store guid in vertex
*/
def
idAttributeName
:
String
/**
* Given a dataType and a reference attribute, how is edge labeled
*/
def
edgeLabel
(
iDataType
:
IDataType
[
_
],
aInfo
:
AttributeInfo
)
:
String
def
traitLabel
(
cls
:
IDataType
[
_
],
traitName
:
String
)
:
String
def
instanceToTraitEdgeDirection
:
String
=
"out"
def
traitToInstanceEdgeDirection
=
instanceToTraitEdgeDirection
match
{
case
"out"
=>
"in"
case
"in"
=>
"out"
case
x
=>
x
}
/**
* The propertyKey used to store the attribute in a Graph Vertex.
* @param dataType
...
...
@@ -101,6 +113,7 @@ trait GraphPersistenceStrategies {
object
GraphPersistenceStrategy1
extends
GraphPersistenceStrategies
{
val
typeAttributeName
=
"typeName"
val
idAttributeName
=
"guid"
def
edgeLabel
(
dataType
:
IDataType
[
_
],
aInfo
:
AttributeInfo
)
=
s
"${dataType.getName}.${aInfo.name}"
...
...
@@ -125,6 +138,16 @@ object GraphPersistenceStrategy1 extends GraphPersistenceStrategies {
def
constructInstance
[
U
](
dataType
:
IDataType
[
U
],
v
:
AnyRef
)
:
U
=
{
dataType
.
getTypeCategory
match
{
case
DataTypes
.
TypeCategory
.
PRIMITIVE
=>
dataType
.
convert
(
v
,
Multiplicity
.
OPTIONAL
)
case
DataTypes
.
TypeCategory
.
STRUCT
if
dataType
.
getName
==
TypeUtils
.
INSTANCE_ID_TYP
.
getName
=>
{
val
sType
=
dataType
.
asInstanceOf
[
StructType
]
val
sInstance
=
sType
.
createInstance
()
val
tV
=
v
.
asInstanceOf
[
TitanVertex
]
sInstance
.
set
(
TypeUtils
.
INSTANCE_ID_TYP_TYPENAME_ATTRNAME
,
tV
.
getProperty
[
java.lang.String
](
typeAttributeName
))
sInstance
.
set
(
TypeUtils
.
INSTANCE_ID_TYP_ID_ATTRNAME
,
tV
.
getProperty
[
java.lang.String
](
idAttributeName
))
dataType
.
convert
(
sInstance
,
Multiplicity
.
OPTIONAL
)
}
case
DataTypes
.
TypeCategory
.
STRUCT
=>
{
val
sType
=
dataType
.
asInstanceOf
[
StructType
]
val
sInstance
=
sType
.
createInstance
()
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/scala/org/apache/hadoop/metadata/query/TypeUtils.scala
View file @
305d16a1
...
...
@@ -65,6 +65,18 @@ object TypeUtils {
aDefs
:_
*
);
}
val
INSTANCE_ID_TYP_ID_ATTRNAME
=
"guid"
val
INSTANCE_ID_TYP_TYPENAME_ATTRNAME
=
"typeName"
val
INSTANCE_ID_TYP_NAME
=
TEMP_STRUCT_NAME_PREFIX
+
"_IdType"
val
INSTANCE_ID_TYP
=
{
val
idAttr
=
new
AttributeDefinition
(
INSTANCE_ID_TYP_ID_ATTRNAME
,
DataTypes
.
STRING_TYPE
.
getName
,
Multiplicity
.
REQUIRED
,
false
,
null
)
val
typNmAttr
=
new
AttributeDefinition
(
INSTANCE_ID_TYP_TYPENAME_ATTRNAME
,
DataTypes
.
STRING_TYPE
.
getName
,
Multiplicity
.
REQUIRED
,
false
,
null
)
typSystem
.
defineQueryResultType
(
INSTANCE_ID_TYP_NAME
,
idAttr
,
typNmAttr
);
}
def
fieldMapping
(
iDataType
:
IDataType
[
_
])
:
Option
[
FieldMapping
]
=
iDataType
match
{
case
c
:
ClassType
=>
Some
(
c
.
fieldMapping
())
case
t
:
TraitType
=>
Some
(
t
.
fieldMapping
())
...
...
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