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
d86caa89
Commit
d86caa89
authored
9 years ago
by
Suma S
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #117 from shwethags/dbparam
handling maps in entities
parents
ca728273
e6c741b4
Hide 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 @
d86caa89
...
...
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.hive.bridge.HiveMetaStoreBridge
;
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.JSONObject
;
import
org.testng.Assert
;
...
...
@@ -32,6 +33,7 @@ import org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test
;
import
java.io.File
;
import
java.util.Map
;
public
class
HiveHookIT
{
private
static
final
String
DGI_URL
=
"http://localhost:21000/"
;
...
...
@@ -76,8 +78,13 @@ public class HiveHookIT {
@Test
public
void
testCreateDatabase
()
throws
Exception
{
String
dbName
=
"db"
+
random
();
runCommand
(
"create database "
+
dbName
);
assertDatabaseIsRegistered
(
dbName
);
runCommand
(
"create database "
+
dbName
+
" WITH DBPROPERTIES ('p1'='v1', 'p2'='v2')"
);
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
runCommand
(
"drop database "
+
dbName
);
...
...
@@ -213,10 +220,10 @@ public class HiveHookIT {
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
(),
dbName
,
CLUSTER_NAME
);
assertEntityIsRegistered
(
query
);
return
assertEntityIsRegistered
(
query
);
}
private
void
assertPartitionIsRegistered
(
String
dbName
,
String
tableName
,
String
value
)
throws
Exception
{
...
...
@@ -233,8 +240,9 @@ public class HiveHookIT {
Assert
.
assertEquals
(
results
.
length
(),
1
);
}
private
void
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
private
String
assertEntityIsRegistered
(
String
dslQuery
)
throws
Exception
{
JSONArray
results
=
dgiCLient
.
searchByDSL
(
dslQuery
);
Assert
.
assertEquals
(
results
.
length
(),
1
);
return
results
.
getJSONObject
(
0
).
getJSONObject
(
"$id$"
).
getString
(
"id"
);
}
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
d86caa89
...
...
@@ -761,8 +761,9 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
IDataType
elementType
=
((
DataTypes
.
MapType
)
attributeInfo
.
dataType
()).
getValueType
();
for
(
Map
.
Entry
entry
:
collection
.
entrySet
())
{
String
myPropertyName
=
propertyName
+
"."
+
entry
.
getKey
().
toString
();
mapCollectionEntryToVertex
(
id
,
instanceVertex
,
attributeInfo
,
String
value
=
mapCollectionEntryToVertex
(
id
,
instanceVertex
,
attributeInfo
,
idToVertexMap
,
elementType
,
entry
.
getValue
(),
myPropertyName
);
instanceVertex
.
setProperty
(
myPropertyName
,
value
);
}
// for dereference on way out
...
...
@@ -1100,7 +1101,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
@SuppressWarnings
(
"unchecked"
)
private
void
mapVertexToMapInstance
(
Vertex
instanceVertex
,
ITypedInstance
typedInstance
,
AttributeInfo
attributeInfo
,
String
propertyName
)
throws
MetadataException
{
final
String
propertyName
)
throws
MetadataException
{
LOG
.
debug
(
"mapping vertex {} to array {}"
,
instanceVertex
,
attributeInfo
.
name
);
List
<
String
>
keys
=
instanceVertex
.
getProperty
(
propertyName
);
if
(
keys
==
null
||
keys
.
size
()
==
0
)
{
...
...
@@ -1112,21 +1113,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
HashMap
values
=
new
HashMap
();
for
(
String
key
:
keys
)
{
String
keyPropertyName
=
propertyName
+
"."
+
key
;
Object
keyValue
=
instanceVertex
.
getProperty
(
keyPropertyName
);
values
.
put
(
key
,
mapVertexToCollectionEntry
(
instanceVertex
,
attributeInfo
,
valueType
,
propertyNam
e
,
propertyName
));
valueType
,
keyValu
e
,
propertyName
));
}
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
,
IDataType
elemType
,
String
attributeName
,
String
relationshipLabel
,
...
...
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