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
e6c741b4
Commit
e6c741b4
authored
May 29, 2015
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling maps in entities
parent
4e1e84b1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
HiveHookIT.java
...java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
+13
-5
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+6
-11
No files found.
addons/hive-bridge/src/test/java/org/apache/hadoop/metadata/hive/hook/HiveHookIT.java
View file @
e6c741b4
...
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
...
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.hive.bridge.HiveMetaStoreBridge
;
import
org.apache.hadoop.metadata.hive.bridge.HiveMetaStoreBridge
;
import
org.apache.hadoop.metadata.hive.model.HiveDataTypes
;
import
org.apache.hadoop.metadata.hive.model.HiveDataTypes
;
import
org.apache.hadoop.metadata.typesystem.Referenceable
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.Assert
;
...
@@ -32,6 +33,7 @@ import org.testng.annotations.BeforeClass;
...
@@ -32,6 +33,7 @@ import org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Map
;
public
class
HiveHookIT
{
public
class
HiveHookIT
{
private
static
final
String
DGI_URL
=
"http://localhost:21000/"
;
private
static
final
String
DGI_URL
=
"http://localhost:21000/"
;
...
@@ -76,8 +78,13 @@ public class HiveHookIT {
...
@@ -76,8 +78,13 @@ public class HiveHookIT {
@Test
@Test
public
void
testCreateDatabase
()
throws
Exception
{
public
void
testCreateDatabase
()
throws
Exception
{
String
dbName
=
"db"
+
random
();
String
dbName
=
"db"
+
random
();
runCommand
(
"create database "
+
dbName
);
runCommand
(
"create database "
+
dbName
+
" WITH DBPROPERTIES ('p1'='v1', 'p2'='v2')"
);
assertDatabaseIsRegistered
(
dbName
);
String
dbId
=
assertDatabaseIsRegistered
(
dbName
);
Referenceable
definition
=
dgiCLient
.
getEntity
(
dbId
);
Map
params
=
(
Map
)
definition
.
get
(
"parameters"
);
Assert
.
assertNotNull
(
params
);
Assert
.
assertEquals
(
params
.
size
(),
2
);
Assert
.
assertEquals
(
params
.
get
(
"p1"
),
"v1"
);
//There should be just one entity per dbname
//There should be just one entity per dbname
runCommand
(
"drop database "
+
dbName
);
runCommand
(
"drop database "
+
dbName
);
...
@@ -213,10 +220,10 @@ public class HiveHookIT {
...
@@ -213,10 +220,10 @@ public class HiveHookIT {
assertEntityIsRegistered
(
query
);
assertEntityIsRegistered
(
query
);
}
}
private
void
assertDatabaseIsRegistered
(
String
dbName
)
throws
Exception
{
private
String
assertDatabaseIsRegistered
(
String
dbName
)
throws
Exception
{
String
query
=
String
.
format
(
"%s where name = '%s' and clusterName = '%s'"
,
HiveDataTypes
.
HIVE_DB
.
getName
(),
String
query
=
String
.
format
(
"%s where name = '%s' and clusterName = '%s'"
,
HiveDataTypes
.
HIVE_DB
.
getName
(),
dbName
,
CLUSTER_NAME
);
dbName
,
CLUSTER_NAME
);
assertEntityIsRegistered
(
query
);
return
assertEntityIsRegistered
(
query
);
}
}
private
void
assertPartitionIsRegistered
(
String
dbName
,
String
tableName
,
String
value
)
throws
Exception
{
private
void
assertPartitionIsRegistered
(
String
dbName
,
String
tableName
,
String
value
)
throws
Exception
{
...
@@ -233,8 +240,9 @@ public class HiveHookIT {
...
@@ -233,8 +240,9 @@ public class HiveHookIT {
Assert
.
assertEquals
(
results
.
length
(),
1
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
}
}
private
void
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
private
String
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
return
results
.
getJSONObject
(
0
).
getJSONObject
(
"$id$"
).
getString
(
"id"
);
}
}
}
}
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
e6c741b4
...
@@ -761,8 +761,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -761,8 +761,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
IDataType
elementType
=
((
DataTypes
.
MapType
)
attributeInfo
.
dataType
()).
getValueType
();
IDataType
elementType
=
((
DataTypes
.
MapType
)
attributeInfo
.
dataType
()).
getValueType
();
for
(
Map
.
Entry
entry
:
collection
.
entrySet
())
{
for
(
Map
.
Entry
entry
:
collection
.
entrySet
())
{
String
myPropertyName
=
propertyName
+
"."
+
entry
.
getKey
().
toString
();
String
myPropertyName
=
propertyName
+
"."
+
entry
.
getKey
().
toString
();
mapCollectionEntryToVertex
(
id
,
instanceVertex
,
attributeInfo
,
String
value
=
mapCollectionEntryToVertex
(
id
,
instanceVertex
,
attributeInfo
,
idToVertexMap
,
elementType
,
entry
.
getValue
(),
myPropertyName
);
idToVertexMap
,
elementType
,
entry
.
getValue
(),
myPropertyName
);
instanceVertex
.
setProperty
(
myPropertyName
,
value
);
}
}
// for dereference on way out
// for dereference on way out
...
@@ -1100,7 +1101,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -1100,7 +1101,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
void
mapVertexToMapInstance
(
Vertex
instanceVertex
,
ITypedInstance
typedInstance
,
private
void
mapVertexToMapInstance
(
Vertex
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
,
AttributeInfo
attributeInfo
,
String
propertyName
)
throws
MetadataException
{
final
String
propertyName
)
throws
MetadataException
{
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
List
<
String
>
keys
=
instanceVertex
.
getProperty
(
propertyName
);
List
<
String
>
keys
=
instanceVertex
.
getProperty
(
propertyName
);
if
(
keys
==
null
||
keys
.
size
()
==
0
)
{
if
(
keys
==
null
||
keys
.
size
()
==
0
)
{
...
@@ -1112,21 +1113,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -1112,21 +1113,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
HashMap
values
=
new
HashMap
();
HashMap
values
=
new
HashMap
();
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
String
keyPropertyName
=
propertyName
+
"."
+
key
;
Object
keyValue
=
instanceVertex
.
getProperty
(
keyPropertyName
);
values
.
put
(
key
,
mapVertexToCollectionEntry
(
instanceVertex
,
attributeInfo
,
values
.
put
(
key
,
mapVertexToCollectionEntry
(
instanceVertex
,
attributeInfo
,
valueType
,
propertyNam
e
,
propertyName
));
valueType
,
keyValu
e
,
propertyName
));
}
}
typedInstance
.
set
(
attributeInfo
.
name
,
values
);
typedInstance
.
set
(
attributeInfo
.
name
,
values
);
}
}
private
String
extractKey
(
String
propertyNameWithSuffix
,
IDataType
keyType
)
{
return
propertyNameWithSuffix
.
substring
(
propertyNameWithSuffix
.
lastIndexOf
(
"."
)
+
1
,
keyType
.
getTypeCategory
()
==
DataTypes
.
TypeCategory
.
PRIMITIVE
?
propertyNameWithSuffix
.
length
()
:
propertyNameWithSuffix
.
lastIndexOf
(
":"
));
}
private
ITypedStruct
getStructInstanceFromVertex
(
Vertex
instanceVertex
,
private
ITypedStruct
getStructInstanceFromVertex
(
Vertex
instanceVertex
,
IDataType
elemType
,
IDataType
elemType
,
String
attributeName
,
String
relationshipLabel
,
String
attributeName
,
String
relationshipLabel
,
...
...
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