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
bf00ea91
Commit
bf00ea91
authored
Dec 22, 2014
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add collection, struct and class/trait stores
parent
6c00ad96
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
163 additions
and
25 deletions
+163
-25
AttributeStores.java
...pache/hadoop/metadata/storage/memory/AttributeStores.java
+59
-2
HierarchicalTypeStore.java
...hadoop/metadata/storage/memory/HierarchicalTypeStore.java
+66
-6
IAttributeStore.java
...pache/hadoop/metadata/storage/memory/IAttributeStore.java
+18
-2
MemRepository.java
.../apache/hadoop/metadata/storage/memory/MemRepository.java
+1
-1
StructStore.java
...rg/apache/hadoop/metadata/storage/memory/StructStore.java
+19
-14
No files found.
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/AttributeStores.java
View file @
bf00ea91
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
package
org
.
apache
.
hadoop
.
metadata
.
storage
.
memory
;
package
org
.
apache
.
hadoop
.
metadata
.
storage
.
memory
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
it.unimi.dsi.fastutil.booleans.BooleanArrayList
;
import
it.unimi.dsi.fastutil.booleans.BooleanArrayList
;
import
it.unimi.dsi.fastutil.bytes.ByteArrayList
;
import
it.unimi.dsi.fastutil.bytes.ByteArrayList
;
...
@@ -26,6 +29,8 @@ import it.unimi.dsi.fastutil.floats.FloatArrayList;
...
@@ -26,6 +29,8 @@ import it.unimi.dsi.fastutil.floats.FloatArrayList;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.longs.LongArrayList
;
import
it.unimi.dsi.fastutil.longs.LongArrayList
;
import
it.unimi.dsi.fastutil.shorts.ShortArrayList
;
import
it.unimi.dsi.fastutil.shorts.ShortArrayList
;
import
org.apache.hadoop.metadata.ITypedStruct
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.ITypedInstance
;
import
org.apache.hadoop.metadata.ITypedInstance
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
...
@@ -71,6 +76,10 @@ public class AttributeStores {
...
@@ -71,6 +76,10 @@ public class AttributeStores {
}
else
{
}
else
{
throw
new
RepositoryException
(
String
.
format
(
"Unknown datatype %s"
,
i
.
dataType
()));
throw
new
RepositoryException
(
String
.
format
(
"Unknown datatype %s"
,
i
.
dataType
()));
}
}
case
ARRAY:
return
new
ImmutableListStore
(
i
);
case
MAP:
return
new
ImmutableMapStore
(
i
);
default
:
default
:
throw
new
RepositoryException
(
String
.
format
(
"Unknown Category for datatype %s"
,
i
.
dataType
()));
throw
new
RepositoryException
(
String
.
format
(
"Unknown Category for datatype %s"
,
i
.
dataType
()));
}
}
...
@@ -167,12 +176,12 @@ public class AttributeStores {
...
@@ -167,12 +176,12 @@ public class AttributeStores {
/*
/*
* store the value from colPos in instance into the list.
* store the value from colPos in instance into the list.
*/
*/
protected
abstract
void
store
(
StructInstance
instance
,
int
colPos
,
int
pos
);
protected
abstract
void
store
(
StructInstance
instance
,
int
colPos
,
int
pos
)
throws
RepositoryException
;
/*
/*
* load the value from pos in list into colPos in instance.
* load the value from pos in list into colPos in instance.
*/
*/
protected
abstract
void
load
(
StructInstance
instance
,
int
colPos
,
int
pos
);
protected
abstract
void
load
(
StructInstance
instance
,
int
colPos
,
int
pos
)
throws
RepositoryException
;
/*
/*
* store the value from colPos in map as attrName
* store the value from colPos in map as attrName
*/
*/
...
@@ -529,4 +538,52 @@ public class AttributeStores {
...
@@ -529,4 +538,52 @@ public class AttributeStores {
}
}
}
}
static
class
ImmutableListStore
extends
ObjectAttributeStore
<
ImmutableList
>
{
public
ImmutableListStore
(
AttributeInfo
attrInfo
)
{
super
(
ImmutableList
.
class
,
attrInfo
);
}
protected
void
store
(
StructInstance
instance
,
int
colPos
,
int
pos
)
{
list
.
set
(
pos
,
instance
.
arrays
[
colPos
]);
}
protected
void
load
(
StructInstance
instance
,
int
colPos
,
int
pos
)
{
instance
.
arrays
[
colPos
]
=
list
.
get
(
pos
);
}
protected
void
store
(
StructInstance
instance
,
int
colPos
,
String
attrName
,
Map
<
String
,
Object
>
m
)
{
m
.
put
(
attrName
,
instance
.
arrays
[
colPos
]);
}
protected
void
load
(
StructInstance
instance
,
int
colPos
,
Object
val
)
{
instance
.
arrays
[
colPos
]
=
(
ImmutableList
)
val
;
}
}
static
class
ImmutableMapStore
extends
ObjectAttributeStore
<
ImmutableMap
>
{
public
ImmutableMapStore
(
AttributeInfo
attrInfo
)
{
super
(
ImmutableMap
.
class
,
attrInfo
);
}
protected
void
store
(
StructInstance
instance
,
int
colPos
,
int
pos
)
{
list
.
set
(
pos
,
instance
.
maps
[
colPos
]);
}
protected
void
load
(
StructInstance
instance
,
int
colPos
,
int
pos
)
{
instance
.
maps
[
colPos
]
=
list
.
get
(
pos
);
}
protected
void
store
(
StructInstance
instance
,
int
colPos
,
String
attrName
,
Map
<
String
,
Object
>
m
)
{
m
.
put
(
attrName
,
instance
.
maps
[
colPos
]);
}
protected
void
load
(
StructInstance
instance
,
int
colPos
,
Object
val
)
{
instance
.
maps
[
colPos
]
=
(
ImmutableMap
)
val
;
}
}
}
}
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/HierarchicalTypeStore.java
View file @
bf00ea91
...
@@ -21,13 +21,17 @@ package org.apache.hadoop.metadata.storage.memory;
...
@@ -21,13 +21,17 @@ package org.apache.hadoop.metadata.storage.memory;
import
com.google.common.collect.ImmutableBiMap
;
import
com.google.common.collect.ImmutableBiMap
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
org.apache.hadoop.metadata.storage.Id
;
import
org.apache.hadoop.metadata.storage.Id
;
import
org.apache.hadoop.metadata.ITypedReferenceableInstance
;
import
org.apache.hadoop.metadata.ITypedReferenceableInstance
;
import
org.apache.hadoop.metadata.storage.Id
;
import
org.apache.hadoop.metadata.storage.Id
;
import
org.apache.hadoop.metadata.storage.ReferenceableInstance
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.types.AttributeInfo
;
import
org.apache.hadoop.metadata.types.AttributeInfo
;
import
org.apache.hadoop.metadata.types.HierarchicalType
;
import
org.apache.hadoop.metadata.types.HierarchicalType
;
import
org.apache.hadoop.metadata.types.IConstructableType
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -36,10 +40,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
...
@@ -36,10 +40,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
public
class
HierarchicalTypeStore
{
public
class
HierarchicalTypeStore
{
final
MemRepository
repository
;
final
MemRepository
repository
;
final
HierarchicalType
hierarchicalType
;
final
IConstructableType
hierarchicalType
;
final
ArrayList
<
String
>
typeNameList
;
final
ImmutableMap
<
AttributeInfo
,
IAttributeStore
>
attrStores
;
final
ImmutableMap
<
AttributeInfo
,
IAttributeStore
>
attrStores
;
final
ImmutableList
<
HierarchicalTypeStore
>
superTypeStores
;
final
ImmutableList
<
HierarchicalTypeStore
>
superTypeStores
;
/**
/**
* Map Id to position in storage lists.
* Map Id to position in storage lists.
*/
*/
...
@@ -47,16 +53,19 @@ public class HierarchicalTypeStore {
...
@@ -47,16 +53,19 @@ public class HierarchicalTypeStore {
List
<
Integer
>
freePositions
;
List
<
Integer
>
freePositions
;
int
nextPos
;
/**
/**
* Lock for each Class/Trait.
* Lock for each Class/Trait.
*/
*/
ReentrantReadWriteLock
lock
;
ReentrantReadWriteLock
lock
;
HierarchicalTypeStore
(
MemRepository
repository
,
HierarchicalType
hierarchicalType
)
throws
RepositoryException
{
HierarchicalTypeStore
(
MemRepository
repository
,
HierarchicalType
hierarchicalType
)
throws
RepositoryException
{
this
.
hierarchicalType
=
hierarchicalType
;
this
.
hierarchicalType
=
(
IConstructableType
)
hierarchicalType
;
this
.
repository
=
repository
;
this
.
repository
=
repository
;
ImmutableMap
.
Builder
<
AttributeInfo
,
IAttributeStore
>
b
=
new
ImmutableBiMap
.
Builder
<
AttributeInfo
,
ImmutableMap
.
Builder
<
AttributeInfo
,
IAttributeStore
>
b
=
new
ImmutableBiMap
.
Builder
<
AttributeInfo
,
IAttributeStore
>();
IAttributeStore
>();
typeNameList
=
Lists
.
newArrayList
((
String
)
null
);
ImmutableList
<
AttributeInfo
>
l
=
hierarchicalType
.
immediateAttrs
;
ImmutableList
<
AttributeInfo
>
l
=
hierarchicalType
.
immediateAttrs
;
for
(
AttributeInfo
i
:
l
)
{
for
(
AttributeInfo
i
:
l
)
{
b
.
put
(
i
,
AttributeStores
.
createStore
(
i
)
);
b
.
put
(
i
,
AttributeStores
.
createStore
(
i
)
);
...
@@ -69,6 +78,8 @@ public class HierarchicalTypeStore {
...
@@ -69,6 +78,8 @@ public class HierarchicalTypeStore {
b1
.
add
(
repository
.
getStore
(
s
));
b1
.
add
(
repository
.
getStore
(
s
));
}
}
superTypeStores
=
b1
.
build
();
superTypeStores
=
b1
.
build
();
nextPos
=
0
;
}
}
/**
/**
...
@@ -81,7 +92,22 @@ public class HierarchicalTypeStore {
...
@@ -81,7 +92,22 @@ public class HierarchicalTypeStore {
* @throws RepositoryException
* @throws RepositoryException
*/
*/
int
assignPosition
(
Id
id
)
throws
RepositoryException
{
int
assignPosition
(
Id
id
)
throws
RepositoryException
{
throw
new
RepositoryException
(
"Not implemented"
);
int
pos
=
-
1
;
if
(
!
freePositions
.
isEmpty
()
)
{
pos
=
freePositions
.
remove
(
0
);
}
else
{
pos
=
nextPos
++;
ensureCapacity
(
pos
);
}
idPosMap
.
put
(
id
,
pos
);
for
(
HierarchicalTypeStore
s
:
superTypeStores
)
{
s
.
assignPosition
(
id
);
}
return
pos
;
}
}
/**
/**
...
@@ -90,7 +116,16 @@ public class HierarchicalTypeStore {
...
@@ -90,7 +116,16 @@ public class HierarchicalTypeStore {
* @throws RepositoryException
* @throws RepositoryException
*/
*/
void
releaseId
(
Id
id
)
{
void
releaseId
(
Id
id
)
{
throw
new
RuntimeException
(
"Not implemented"
);
Integer
pos
=
idPosMap
.
get
(
id
);
if
(
pos
!=
null
)
{
idPosMap
.
remove
(
id
);
freePositions
.
add
(
pos
);
for
(
HierarchicalTypeStore
s
:
superTypeStores
)
{
s
.
releaseId
(
id
);
}
}
}
}
/**
/**
...
@@ -100,8 +135,17 @@ public class HierarchicalTypeStore {
...
@@ -100,8 +135,17 @@ public class HierarchicalTypeStore {
* @param i
* @param i
* @throws RepositoryException
* @throws RepositoryException
*/
*/
void
store
(
ITypedReferenceableInstance
i
)
throws
RepositoryException
{
void
store
(
ReferenceableInstance
i
)
throws
RepositoryException
{
int
pos
=
idPosMap
.
get
(
i
.
getId
());
typeNameList
.
set
(
pos
,
i
.
getTypeName
());
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
store
(
pos
,
hierarchicalType
,
i
);
}
for
(
HierarchicalTypeStore
s
:
superTypeStores
)
{
s
.
store
(
i
);
}
}
}
/**
/**
...
@@ -110,7 +154,23 @@ public class HierarchicalTypeStore {
...
@@ -110,7 +154,23 @@ public class HierarchicalTypeStore {
* @param i
* @param i
* @throws RepositoryException
* @throws RepositoryException
*/
*/
void
load
(
ITypedReferenceableInstance
i
)
throws
RepositoryException
{
void
load
(
ReferenceableInstance
i
)
throws
RepositoryException
{
int
pos
=
idPosMap
.
get
(
i
.
getId
());
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
load
(
pos
,
hierarchicalType
,
i
);
}
for
(
HierarchicalTypeStore
s
:
superTypeStores
)
{
s
.
load
(
i
);
}
}
public
void
ensureCapacity
(
int
pos
)
throws
RepositoryException
{
typeNameList
.
ensureCapacity
(
pos
);
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
ensureCapacity
(
pos
);
}
}
}
}
}
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/IAttributeStore.java
View file @
bf00ea91
package
org
.
apache
.
hadoop
.
metadata
.
storage
.
memory
;
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
hadoop
.
metadata
.
storage
.
memory
;
import
org.apache.hadoop.metadata.ITypedInstance
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.types.IConstructableType
;
import
org.apache.hadoop.metadata.types.IConstructableType
;
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/MemRepository.java
View file @
bf00ea91
...
@@ -162,7 +162,7 @@ public class MemRepository implements IRepository {
...
@@ -162,7 +162,7 @@ public class MemRepository implements IRepository {
for
(
ITypedReferenceableInstance
instance
:
newInstances
)
{
for
(
ITypedReferenceableInstance
instance
:
newInstances
)
{
HierarchicalTypeStore
st
=
typeStores
.
get
(
instance
.
getTypeName
());
HierarchicalTypeStore
st
=
typeStores
.
get
(
instance
.
getTypeName
());
st
.
store
(
instance
);
st
.
store
(
(
ReferenceableInstance
)
instance
);
}
}
}
catch
(
RepositoryException
re
)
{
}
catch
(
RepositoryException
re
)
{
for
(
ITypedReferenceableInstance
instance
:
newInstances
)
{
for
(
ITypedReferenceableInstance
instance
:
newInstances
)
{
...
...
typesystem/src/main/java/org/apache/hadoop/metadata/storage/memory/StructStore.java
View file @
bf00ea91
...
@@ -21,6 +21,7 @@ package org.apache.hadoop.metadata.storage.memory;
...
@@ -21,6 +21,7 @@ package org.apache.hadoop.metadata.storage.memory;
import
com.google.common.collect.ImmutableBiMap
;
import
com.google.common.collect.ImmutableBiMap
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.storage.StructInstance
;
import
org.apache.hadoop.metadata.types.IConstructableType
;
import
org.apache.hadoop.metadata.types.IConstructableType
;
...
@@ -55,32 +56,36 @@ public abstract class StructStore extends AttributeStores.AbstractAttributeStore
...
@@ -55,32 +56,36 @@ public abstract class StructStore extends AttributeStores.AbstractAttributeStore
}
}
@Override
protected
void
store
(
StructInstance
instance
,
int
colPos
,
int
pos
)
throws
RepositoryException
{
public
void
store
(
int
pos
,
IConstructableType
type
,
StructInstance
instance
)
throws
RepositoryException
{
List
<
String
>
attrNames
=
type
.
getNames
(
attrInfo
);
String
attrName
=
attrNames
.
get
(
0
);
int
nullPos
=
instance
.
fieldMapping
().
fieldNullPos
.
get
(
attrName
);
int
colPos
=
instance
.
fieldMapping
().
fieldPos
.
get
(
attrName
);
nullList
.
set
(
pos
,
instance
.
nullFlags
[
nullPos
]);
if
(
!
instance
.
nullFlags
[
nullPos
]
)
{
StructInstance
s
=
instance
.
structs
[
colPos
];
StructInstance
s
=
instance
.
structs
[
colPos
];
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
e
.
getValue
().
store
(
pos
,
structType
,
s
);
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
store
(
pos
,
structType
,
s
);
}
}
}
}
if
(
attrNames
.
size
()
>
1
)
{
protected
void
load
(
StructInstance
instance
,
int
colPos
,
int
pos
)
throws
RepositoryException
{
storeHiddenVals
(
pos
,
type
,
instance
);
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
load
(
pos
,
structType
,
instance
);
}
}
}
}
@Override
protected
void
store
(
StructInstance
instance
,
int
colPos
,
String
attrName
,
Map
<
String
,
Object
>
m
)
{
public
void
load
(
int
pos
,
IConstructableType
type
,
StructInstance
instance
)
throws
RepositoryException
{
m
.
put
(
attrName
,
instance
.
structs
[
colPos
]);
}
protected
void
load
(
StructInstance
instance
,
int
colPos
,
Object
val
)
{
instance
.
structs
[
colPos
]
=
(
StructInstance
)
val
;
}
}
@Override
@Override
public
void
ensureCapacity
(
int
pos
)
throws
RepositoryException
{
public
void
ensureCapacity
(
int
pos
)
throws
RepositoryException
{
for
(
Map
.
Entry
<
AttributeInfo
,
IAttributeStore
>
e
:
attrStores
.
entrySet
())
{
IAttributeStore
attributeStore
=
e
.
getValue
();
attributeStore
.
ensureCapacity
(
pos
);
}
}
nullList
.
ensureCapacity
(
pos
);
}
}
}
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