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
3c350780
Commit
3c350780
authored
Jan 09, 2015
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change id to String to allow for Guids
parent
34e7f58a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
Id.java
.../src/main/java/org/apache/hadoop/metadata/storage/Id.java
+17
-8
MemRepository.java
.../apache/hadoop/metadata/storage/memory/MemRepository.java
+1
-1
Serialization.scala
...scala/org/apache/hadoop/metadata/json/Serialization.scala
+10
-4
No files found.
typesystem/src/main/java/org/apache/hadoop/metadata/storage/Id.java
View file @
3c350780
...
@@ -31,22 +31,31 @@ import java.util.Date;
...
@@ -31,22 +31,31 @@ import java.util.Date;
public
class
Id
implements
ITypedReferenceableInstance
{
public
class
Id
implements
ITypedReferenceableInstance
{
public
final
lo
ng
id
;
public
final
Stri
ng
id
;
public
final
String
className
;
public
final
String
className
;
public
final
int
version
;
public
final
int
version
;
public
Id
(
lo
ng
id
,
int
version
,
String
className
)
{
public
Id
(
Stri
ng
id
,
int
version
,
String
className
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
className
=
className
;
this
.
className
=
className
;
this
.
version
=
version
;
this
.
version
=
version
;
}
}
public
Id
(
long
id
,
int
version
,
String
className
)
{
this
(
""
+
id
,
version
,
className
);
}
public
Id
(
String
className
)
{
public
Id
(
String
className
)
{
this
(
-
System
.
nanoTime
(
),
0
,
className
);
this
(
""
+
(-
System
.
nanoTime
()
),
0
,
className
);
}
}
public
boolean
isUnassigned
()
{
public
boolean
isUnassigned
()
{
return
id
<
0
;
try
{
long
l
=
Long
.
parseLong
(
id
);
return
l
<
0
;
}
catch
(
NumberFormatException
ne
)
{
return
false
;
}
}
}
public
String
toString
()
{
public
String
toString
()
{
...
@@ -56,20 +65,20 @@ public class Id implements ITypedReferenceableInstance {
...
@@ -56,20 +65,20 @@ public class Id implements ITypedReferenceableInstance {
@Override
@Override
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
!
ITypedReferenceableInstance
.
class
.
isAssignableFrom
(
o
.
getClass
()
))
return
false
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
(
))
return
false
;
Id
id1
=
(
(
ITypedReferenceableInstance
)
o
).
getId
()
;
Id
id1
=
(
Id
)
o
;
if
(
id
!=
id1
.
id
)
return
false
;
if
(
version
!=
id1
.
version
)
return
false
;
if
(
version
!=
id1
.
version
)
return
false
;
if
(!
className
.
equals
(
id1
.
className
))
return
false
;
if
(!
className
.
equals
(
id1
.
className
))
return
false
;
if
(!
id
.
equals
(
id1
.
id
))
return
false
;
return
true
;
return
true
;
}
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
int
result
=
(
int
)
(
id
^
(
id
>>>
32
)
);
int
result
=
id
.
hashCode
(
);
result
=
31
*
result
+
className
.
hashCode
();
result
=
31
*
result
+
className
.
hashCode
();
result
=
31
*
result
+
version
;
result
=
31
*
result
+
version
;
return
result
;
return
result
;
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/MemRepository.java
View file @
3c350780
...
@@ -63,7 +63,7 @@ public class MemRepository implements IRepository {
...
@@ -63,7 +63,7 @@ public class MemRepository implements IRepository {
@Override
@Override
public
Id
newId
(
String
typeName
)
{
public
Id
newId
(
String
typeName
)
{
return
new
Id
(
ID_SEQ
.
incrementAndGet
(),
0
,
typeName
);
return
new
Id
(
""
+
ID_SEQ
.
incrementAndGet
(),
0
,
typeName
);
}
}
/**
/**
...
...
typesystem/src/main/scala/org/apache/hadoop/metadata/json/Serialization.scala
View file @
3c350780
...
@@ -52,12 +52,12 @@ class IdSerializer extends CustomSerializer[Id](format => ( {
...
@@ -52,12 +52,12 @@ class IdSerializer extends CustomSerializer[Id](format => ( {
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
case
JObject
(
JField
(
"id"
,
JString
(
id
))
::
case
JObject
(
JField
(
"id"
,
JString
(
id
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"version"
,
JString
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
JField
(
"version"
,
JString
(
version
))
::
Nil
)
=>
new
Id
(
id
,
version
.
toInt
,
className
)
case
JObject
(
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
case
JObject
(
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"id"
,
JString
(
id
))
::
JField
(
"id"
,
JString
(
id
))
::
JField
(
"version"
,
JString
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
JField
(
"version"
,
JString
(
version
))
::
Nil
)
=>
new
Id
(
id
,
version
.
toInt
,
className
)
},
{
},
{
case
id
:
Id
=>
JObject
(
JField
(
"id"
,
J
Int
(
id
.
id
)),
case
id
:
Id
=>
JObject
(
JField
(
"id"
,
J
String
(
id
.
id
)),
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
id
.
className
)),
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
id
.
className
)),
JField
(
"version"
,
JInt
(
id
.
version
)))
JField
(
"version"
,
JInt
(
id
.
version
)))
}
}
...
@@ -106,6 +106,9 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
...
@@ -106,6 +106,9 @@ class TypedReferenceableInstanceSerializer(val typSystem : Option[MetadataServic
case
JObject
(
JField
(
"id"
,
JInt
(
id
))
::
case
JObject
(
JField
(
"id"
,
JInt
(
id
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
case
JObject
(
JField
(
"id"
,
JString
(
id
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
,
version
.
toInt
,
className
)
case
JObject
(
fs
)
=>
case
JObject
(
fs
)
=>
var
typField
:
Option
[
JField
]
=
None
var
typField
:
Option
[
JField
]
=
None
var
idField
:
Option
[
JField
]
=
None
var
idField
:
Option
[
JField
]
=
None
...
@@ -205,7 +208,7 @@ object Serialization {
...
@@ -205,7 +208,7 @@ object Serialization {
Extraction
.
extract
[
ITypedReferenceableInstance
](
value
)
Extraction
.
extract
[
ITypedReferenceableInstance
](
value
)
}
}
def
serializeId
(
id
:
Id
)
=
JObject
(
JField
(
"id"
,
J
Int
(
id
.
id
)),
def
serializeId
(
id
:
Id
)
=
JObject
(
JField
(
"id"
,
J
String
(
id
.
id
)),
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
id
.
className
)),
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
id
.
className
)),
JField
(
"version"
,
JInt
(
id
.
version
)))
JField
(
"version"
,
JInt
(
id
.
version
)))
...
@@ -256,6 +259,9 @@ object Serialization {
...
@@ -256,6 +259,9 @@ object Serialization {
case
JObject
(
JField
(
"id"
,
JInt
(
id
))
::
case
JObject
(
JField
(
"id"
,
JInt
(
id
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
.
toLong
,
version
.
toInt
,
className
)
case
JObject
(
JField
(
"id"
,
JString
(
id
))
::
JField
(
Serialization
.
STRUCT_TYPE_FIELD_NAME
,
JString
(
className
))
::
JField
(
"version"
,
JInt
(
version
))
::
Nil
)
=>
new
Id
(
id
,
version
.
toInt
,
className
)
}
}
def
toJson
(
value
:
ITypedReferenceableInstance
)
:
String
=
{
def
toJson
(
value
:
ITypedReferenceableInstance
)
:
String
=
{
...
...
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