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
f7d633de
Commit
f7d633de
authored
May 26, 2015
by
Shwetha G S
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #104 from shwethags/utf
support for utf8 characters
parents
fa81143d
f7da366d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
11 deletions
+73
-11
pom.xml
pom.xml
+6
-0
GraphBackedMetadataRepositoryTest.java
...a/repository/graph/GraphBackedMetadataRepositoryTest.java
+25
-0
pom.xml
typesystem/pom.xml
+6
-0
AttributeInfo.java
...pache/hadoop/metadata/typesystem/types/AttributeInfo.java
+0
-1
TypeSystem.java
...g/apache/hadoop/metadata/typesystem/types/TypeSystem.java
+0
-3
TypeUtils.java
...rg/apache/hadoop/metadata/typesystem/types/TypeUtils.java
+0
-7
TypeSystemTest.java
...ache/hadoop/metadata/typesystem/types/TypeSystemTest.java
+36
-0
No files found.
pom.xml
View file @
f7d633de
...
@@ -614,6 +614,12 @@
...
@@ -614,6 +614,12 @@
<version>
1.8.5
</version>
<version>
1.8.5
</version>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.4
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
repository/src/test/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepositoryTest.java
View file @
f7d633de
...
@@ -23,6 +23,7 @@ import com.thinkaurelius.titan.core.TitanGraph;
...
@@ -23,6 +23,7 @@ import com.thinkaurelius.titan.core.TitanGraph;
import
com.tinkerpop.blueprints.Compare
;
import
com.tinkerpop.blueprints.Compare
;
import
com.tinkerpop.blueprints.GraphQuery
;
import
com.tinkerpop.blueprints.GraphQuery
;
import
com.tinkerpop.blueprints.Vertex
;
import
com.tinkerpop.blueprints.Vertex
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.apache.hadoop.metadata.RepositoryMetadataModule
;
import
org.apache.hadoop.metadata.RepositoryMetadataModule
;
import
org.apache.hadoop.metadata.TestUtils
;
import
org.apache.hadoop.metadata.TestUtils
;
import
org.apache.hadoop.metadata.discovery.graph.GraphBackedDiscoveryService
;
import
org.apache.hadoop.metadata.discovery.graph.GraphBackedDiscoveryService
;
...
@@ -59,6 +60,9 @@ import java.util.Iterator;
...
@@ -59,6 +60,9 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
/**
/**
* GraphBackedMetadataRepository test
* GraphBackedMetadataRepository test
*
*
...
@@ -588,4 +592,25 @@ public class GraphBackedMetadataRepositoryTest {
...
@@ -588,4 +592,25 @@ public class GraphBackedMetadataRepositoryTest {
ClassType
tableType
=
typeSystem
.
getDataType
(
ClassType
.
class
,
TABLE_TYPE
);
ClassType
tableType
=
typeSystem
.
getDataType
(
ClassType
.
class
,
TABLE_TYPE
);
return
tableType
.
convert
(
tableInstance
,
Multiplicity
.
REQUIRED
);
return
tableType
.
convert
(
tableInstance
,
Multiplicity
.
REQUIRED
);
}
}
private
String
random
()
{
return
RandomStringUtils
.
random
(
10
);
}
@Test
public
void
testUTFValues
()
throws
Exception
{
Referenceable
hrDept
=
new
Referenceable
(
"Department"
);
Referenceable
john
=
new
Referenceable
(
"Person"
);
john
.
set
(
"name"
,
random
());
john
.
set
(
"department"
,
hrDept
);
hrDept
.
set
(
"name"
,
random
());
hrDept
.
set
(
"employees"
,
ImmutableList
.
of
(
john
));
ClassType
deptType
=
typeSystem
.
getDataType
(
ClassType
.
class
,
"Department"
);
ITypedReferenceableInstance
hrDept2
=
deptType
.
convert
(
hrDept
,
Multiplicity
.
REQUIRED
);
guid
=
repositoryService
.
createEntity
(
hrDept2
);
Assert
.
assertNotNull
(
guid
);
}
}
}
typesystem/pom.xml
View file @
f7d633de
...
@@ -124,6 +124,12 @@
...
@@ -124,6 +124,12 @@
<groupId>
com.google.inject
</groupId>
<groupId>
com.google.inject
</groupId>
<artifactId>
guice
</artifactId>
<artifactId>
guice
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/AttributeInfo.java
View file @
f7d633de
...
@@ -38,7 +38,6 @@ public class AttributeInfo {
...
@@ -38,7 +38,6 @@ public class AttributeInfo {
private
IDataType
dataType
;
private
IDataType
dataType
;
AttributeInfo
(
TypeSystem
t
,
AttributeDefinition
def
,
Map
<
String
,
IDataType
>
tempTypes
)
throws
MetadataException
{
AttributeInfo
(
TypeSystem
t
,
AttributeDefinition
def
,
Map
<
String
,
IDataType
>
tempTypes
)
throws
MetadataException
{
TypeUtils
.
validateName
(
def
.
name
);
this
.
name
=
def
.
name
;
this
.
name
=
def
.
name
;
this
.
dataType
=
(
tempTypes
!=
null
&&
tempTypes
.
containsKey
(
def
.
dataTypeName
))
?
this
.
dataType
=
(
tempTypes
!=
null
&&
tempTypes
.
containsKey
(
def
.
dataTypeName
))
?
tempTypes
.
get
(
def
.
dataTypeName
)
:
t
.
getDataType
(
IDataType
.
class
,
def
.
dataTypeName
);
tempTypes
.
get
(
def
.
dataTypeName
)
:
t
.
getDataType
(
IDataType
.
class
,
def
.
dataTypeName
);
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java
View file @
f7d633de
...
@@ -352,7 +352,6 @@ public class TypeSystem {
...
@@ -352,7 +352,6 @@ public class TypeSystem {
private
void
step1
()
throws
MetadataException
{
private
void
step1
()
throws
MetadataException
{
for
(
StructTypeDefinition
sDef
:
structDefs
)
{
for
(
StructTypeDefinition
sDef
:
structDefs
)
{
assert
sDef
.
typeName
!=
null
;
assert
sDef
.
typeName
!=
null
;
TypeUtils
.
validateName
(
sDef
.
typeName
);
if
(
dataType
(
sDef
.
typeName
)
!=
null
)
{
if
(
dataType
(
sDef
.
typeName
)
!=
null
)
{
throw
new
MetadataException
(
throw
new
MetadataException
(
String
.
format
(
"Cannot redefine type %s"
,
sDef
.
typeName
));
String
.
format
(
"Cannot redefine type %s"
,
sDef
.
typeName
));
...
@@ -365,7 +364,6 @@ public class TypeSystem {
...
@@ -365,7 +364,6 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
TraitType
>
traitDef
:
traitDefs
)
{
for
(
HierarchicalTypeDefinition
<
TraitType
>
traitDef
:
traitDefs
)
{
assert
traitDef
.
typeName
!=
null
;
assert
traitDef
.
typeName
!=
null
;
TypeUtils
.
validateName
(
traitDef
.
typeName
);
if
(
types
.
containsKey
(
traitDef
.
typeName
))
{
if
(
types
.
containsKey
(
traitDef
.
typeName
))
{
throw
new
MetadataException
(
throw
new
MetadataException
(
String
.
format
(
"Cannot redefine type %s"
,
traitDef
.
typeName
));
String
.
format
(
"Cannot redefine type %s"
,
traitDef
.
typeName
));
...
@@ -380,7 +378,6 @@ public class TypeSystem {
...
@@ -380,7 +378,6 @@ public class TypeSystem {
for
(
HierarchicalTypeDefinition
<
ClassType
>
classDef
:
classDefs
)
{
for
(
HierarchicalTypeDefinition
<
ClassType
>
classDef
:
classDefs
)
{
assert
classDef
.
typeName
!=
null
;
assert
classDef
.
typeName
!=
null
;
TypeUtils
.
validateName
(
classDef
.
typeName
);
if
(
types
.
containsKey
(
classDef
.
typeName
))
{
if
(
types
.
containsKey
(
classDef
.
typeName
))
{
throw
new
MetadataException
(
throw
new
MetadataException
(
String
.
format
(
"Cannot redefine type %s"
,
classDef
.
typeName
));
String
.
format
(
"Cannot redefine type %s"
,
classDef
.
typeName
));
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeUtils.java
View file @
f7d633de
...
@@ -50,13 +50,6 @@ public class TypeUtils {
...
@@ -50,13 +50,6 @@ public class TypeUtils {
}
}
}
}
public
static
void
validateName
(
String
name
)
throws
MetadataException
{
if
(!
NAME_PATTERN
.
matcher
(
name
).
matches
())
{
throw
new
MetadataException
(
String
.
format
(
"Unsupported name for an attribute '%s'"
,
name
));
}
}
public
static
String
parseAsArrayType
(
String
typeName
)
{
public
static
String
parseAsArrayType
(
String
typeName
)
{
Matcher
m
=
ARRAY_TYPE_NAME_PATTERN
.
matcher
(
typeName
);
Matcher
m
=
ARRAY_TYPE_NAME_PATTERN
.
matcher
(
typeName
);
return
m
.
matches
()
?
m
.
group
(
1
)
:
null
;
return
m
.
matches
()
?
m
.
group
(
1
)
:
null
;
...
...
typesystem/src/test/java/org/apache/hadoop/metadata/typesystem/types/TypeSystemTest.java
View file @
f7d633de
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
;
package
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil
;
import
org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.AfterMethod
;
...
@@ -29,6 +30,11 @@ import scala.actors.threadpool.Arrays;
...
@@ -29,6 +30,11 @@ import scala.actors.threadpool.Arrays;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
import
static
org
.
apache
.
hadoop
.
metadata
.
typesystem
.
types
.
utils
.
TypesUtil
.
createTraitTypeDef
;
public
class
TypeSystemTest
extends
BaseTest
{
public
class
TypeSystemTest
extends
BaseTest
{
@BeforeClass
@BeforeClass
...
@@ -100,4 +106,34 @@ public class TypeSystemTest extends BaseTest {
...
@@ -100,4 +106,34 @@ public class TypeSystemTest extends BaseTest {
Assert
.
assertFalse
(
Collections
.
disjoint
(
traitsNames
,
traits
));
Assert
.
assertFalse
(
Collections
.
disjoint
(
traitsNames
,
traits
));
}
}
private
String
random
()
{
return
RandomStringUtils
.
random
(
10
);
}
@Test
public
void
testUTFNames
()
throws
Exception
{
TypeSystem
ts
=
getTypeSystem
();
String
enumType
=
random
();
EnumTypeDefinition
orgLevelEnum
=
new
EnumTypeDefinition
(
enumType
,
new
EnumValue
(
random
(),
1
),
new
EnumValue
(
random
(),
2
));
ts
.
defineEnumType
(
orgLevelEnum
);
String
structName
=
random
();
String
attrType
=
random
();
StructTypeDefinition
structType
=
createStructTypeDef
(
structName
,
createRequiredAttrDef
(
attrType
,
DataTypes
.
STRING_TYPE
));
String
className
=
random
();
HierarchicalTypeDefinition
<
ClassType
>
classType
=
createClassTypeDef
(
className
,
ImmutableList
.<
String
>
of
(),
createRequiredAttrDef
(
attrType
,
DataTypes
.
STRING_TYPE
));
String
traitName
=
random
();
HierarchicalTypeDefinition
<
TraitType
>
traitType
=
createTraitTypeDef
(
traitName
,
ImmutableList
.<
String
>
of
(),
createRequiredAttrDef
(
attrType
,
DataTypes
.
INT_TYPE
));
ts
.
defineTypes
(
ImmutableList
.
of
(
structType
),
ImmutableList
.
of
(
traitType
),
ImmutableList
.
of
(
classType
));
}
}
}
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