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
3e1637a4
Commit
3e1637a4
authored
Jun 11, 2015
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG-39239 Not storing arrays and maps in type system
parent
13aae4bf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
36 deletions
+40
-36
GraphBackedTypeStore.java
...ache/atlas/repository/typestore/GraphBackedTypeStore.java
+24
-27
package.scala
...s/src/main/scala/org/apache/atlas/tools/dsl/package.scala
+1
-1
DSLTest.scala
...s/src/test/scala/org/apache/atlas/tools/dsl/DSLTest.scala
+3
-3
TypeSystem.java
...in/java/org/apache/atlas/typesystem/types/TypeSystem.java
+7
-5
TypesJerseyResourceIT.java
...org/apache/atlas/web/resources/TypesJerseyResourceIT.java
+5
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/typestore/GraphBackedTypeStore.java
View file @
3e1637a4
...
...
@@ -76,32 +76,29 @@ public class GraphBackedTypeStore implements ITypeStore {
@Override
@GraphTransaction
public
void
store
(
TypeSystem
typeSystem
,
ImmutableList
<
String
>
typeNames
)
throws
AtlasException
{
ImmutableList
<
String
>
coreTypes
=
typeSystem
.
getCoreTypes
();
for
(
String
typeName
:
typeNames
)
{
if
(!
coreTypes
.
contains
(
typeName
))
{
IDataType
dataType
=
typeSystem
.
getDataType
(
IDataType
.
class
,
typeName
);
LOG
.
debug
(
"Processing {}.{} in type store"
,
dataType
.
getTypeCategory
(),
dataType
.
getName
());
switch
(
dataType
.
getTypeCategory
())
{
case
ENUM:
storeInGraph
((
EnumType
)
dataType
);
break
;
case
STRUCT:
StructType
structType
=
(
StructType
)
dataType
;
storeInGraph
(
typeSystem
,
dataType
.
getTypeCategory
(),
dataType
.
getName
(),
ImmutableList
.
copyOf
(
structType
.
infoToNameMap
.
keySet
()),
ImmutableList
.<
String
>
of
());
break
;
case
TRAIT:
case
CLASS:
HierarchicalType
type
=
(
HierarchicalType
)
dataType
;
storeInGraph
(
typeSystem
,
dataType
.
getTypeCategory
(),
dataType
.
getName
(),
type
.
immediateAttrs
,
type
.
superTypes
);
break
;
default
:
//Ignore primitive/collection types as they are covered under references
break
;
}
IDataType
dataType
=
typeSystem
.
getDataType
(
IDataType
.
class
,
typeName
);
LOG
.
debug
(
"Processing {}.{} in type store"
,
dataType
.
getTypeCategory
(),
dataType
.
getName
());
switch
(
dataType
.
getTypeCategory
())
{
case
ENUM:
storeInGraph
((
EnumType
)
dataType
);
break
;
case
STRUCT:
StructType
structType
=
(
StructType
)
dataType
;
storeInGraph
(
typeSystem
,
dataType
.
getTypeCategory
(),
dataType
.
getName
(),
ImmutableList
.
copyOf
(
structType
.
infoToNameMap
.
keySet
()),
ImmutableList
.<
String
>
of
());
break
;
case
TRAIT:
case
CLASS:
HierarchicalType
type
=
(
HierarchicalType
)
dataType
;
storeInGraph
(
typeSystem
,
dataType
.
getTypeCategory
(),
dataType
.
getName
(),
type
.
immediateAttrs
,
type
.
superTypes
);
break
;
default
:
//Ignore primitive/collection types as they are covered under references
break
;
}
}
}
...
...
@@ -209,7 +206,7 @@ public class GraphBackedTypeStore implements ITypeStore {
}
private
void
addEdge
(
Vertex
fromVertex
,
Vertex
toVertex
,
String
label
)
{
LOG
.
debug
(
"Adding edge from {} to {} with label {}"
+
toString
(
fromVertex
),
toString
(
toVertex
),
label
);
LOG
.
debug
(
"Adding edge from {} to {} with label {}"
,
toString
(
fromVertex
),
toString
(
toVertex
),
label
);
titanGraph
.
addEdge
(
null
,
fromVertex
,
toVertex
,
label
);
}
...
...
@@ -297,7 +294,7 @@ public class GraphBackedTypeStore implements ITypeStore {
}
private
String
toString
(
Vertex
vertex
)
{
return
PROPERTY_PREFIX
+
"."
+
vertex
.
getProperty
(
Constants
.
TYPENAME_PROPERTY_KEY
);
return
PROPERTY_PREFIX
+
vertex
.
getProperty
(
Constants
.
TYPENAME_PROPERTY_KEY
);
}
/**
...
...
tools/src/main/scala/org/apache/atlas/tools/dsl/package.scala
View file @
3e1637a4
...
...
@@ -69,7 +69,7 @@ package object dsl {
new
AttributeDefinition
(
name
,
dT
.
getName
,
m
,
isComposite
,
reverseAttributeName
)
}
def
listTypes
=
(
ts
.
getTypeNames
--
ts
.
getCoreTypes
)
.
sorted
.
toList
.
mkString
(
"["
,
","
,
"]"
)
def
listTypes
=
ts
.
getTypeNames
.
sorted
.
toList
.
mkString
(
"["
,
","
,
"]"
)
def
ts
=
TypeSystem
.
getInstance
...
...
tools/src/test/scala/org/apache/atlas/tools/dsl/DSLTest.scala
View file @
3e1637a4
...
...
@@ -85,7 +85,7 @@ class DSLTest {
attrDef
(
"o"
,
mapType
(
STRING_TYPE
,
DOUBLE_TYPE
)))
// 2. 'mytype' available as a a Type
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[
array<bigdecimal>,array<int>,map<string,double>,
mytype,t1,t2]"
)
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[mytype,t1,t2]"
)
// 3. Create a 'mytype' instance from Json
val
i
=
createInstance
(
"mytype"
,
"""
...
...
@@ -125,7 +125,7 @@ class DSLTest {
@Test
def
test2
{
// 1. Existing Types in System
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[
array<bigdecimal>,array<int>,map<string,double>,
t1,t2]"
)
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[t1,t2]"
)
val
addrType
=
defineStructType
(
"addressType"
,
attrDef
(
"houseNum"
,
INT_TYPE
,
ATTR_REQUIRED
),
...
...
@@ -143,7 +143,7 @@ class DSLTest {
)
// 2. updated Types in System
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[addressType,
array<bigdecimal>,array<int>,map<string,double>,
personType,t1,t2]"
)
Assert
.
assertEquals
(
s
"${listTypes}"
,
"[addressType,personType,t1,t2]"
)
// 3. Construct a Person in Code
...
...
typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
View file @
3e1637a4
...
...
@@ -85,7 +85,9 @@ public class TypeSystem {
}
public
ImmutableList
<
String
>
getTypeNames
()
{
return
ImmutableList
.
copyOf
(
types
.
keySet
());
List
<
String
>
typeNames
=
new
ArrayList
<>(
types
.
keySet
());
typeNames
.
removeAll
(
getCoreTypes
());
return
ImmutableList
.
copyOf
(
typeNames
);
}
public
ImmutableList
<
String
>
getTypeNamesByCategory
(
DataTypes
.
TypeCategory
typeCategory
)
{
...
...
@@ -259,8 +261,8 @@ public class TypeSystem {
public
DataTypes
.
ArrayType
defineArrayType
(
IDataType
elemType
)
throws
AtlasException
{
assert
elemType
!=
null
;
DataTypes
.
ArrayType
dT
=
new
DataTypes
.
ArrayType
(
elemType
);
types
.
put
(
dT
.
getName
(),
dT
);
typeCategoriesToTypeNamesMap
.
put
(
DataTypes
.
TypeCategory
.
ARRAY
,
dT
.
getName
());
//
types.put(dT.getName(), dT);
//
typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.ARRAY, dT.getName());
return
dT
;
}
...
...
@@ -269,8 +271,8 @@ public class TypeSystem {
assert
keyType
!=
null
;
assert
valueType
!=
null
;
DataTypes
.
MapType
dT
=
new
DataTypes
.
MapType
(
keyType
,
valueType
);
types
.
put
(
dT
.
getName
(),
dT
);
typeCategoriesToTypeNamesMap
.
put
(
DataTypes
.
TypeCategory
.
MAP
,
dT
.
getName
());
//
types.put(dT.getName(), dT);
//
typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.MAP, dT.getName());
return
dT
;
}
...
...
webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
View file @
3e1637a4
...
...
@@ -157,6 +157,11 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
final
JSONArray
list
=
response
.
getJSONArray
(
AtlasClient
.
RESULTS
);
Assert
.
assertNotNull
(
list
);
//Verify that primitive and core types are not returned
String
typesString
=
list
.
join
(
" "
);
Assert
.
assertFalse
(
typesString
.
contains
(
" \"__IdType\" "
));
Assert
.
assertFalse
(
typesString
.
contains
(
" \"string\" "
));
}
@Test
...
...
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