public class DirectWriteHBaseStore extends AbstractDirectWriteStore<HBasePersistenceBackend>
AbstractDirectWriteStore
that translates model-level operations to HBase operations.
This class implements the PersistentStore
interface that defines a set of operations to implement in order to
allow EMF persistence delegation. If this store is used, every method call and property access on PersistentEObject
is forwarded to this class, that takes care of the serialization/deserialization from/to HBase.
For historical purposes this class does not use a HBasePersistenceBackend
, instead, it accesses HBase
directly using the low-level database API.
This store can be used as a base store that can be complemented by plugging decorator stores on top of it (see AbstractPersistentStoreDecorator
subclasses) to provide additional features such as caching or logging.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CACHE_SIZE
The default cache size (10 000).
|
protected static byte[] |
PROPERTY_FAMILY
The column family holding properties.
|
protected Table |
table
The HBase table used to access the model.
|
backend
NO_INDEX
Constructor and Description |
---|
DirectWriteHBaseStore(Resource.Internal resource)
Constructs a new
DirectWriteHBaseStore on the given resource . |
Modifier and Type | Method and Description |
---|---|
protected void |
addAttribute(PersistentEObject object,
EAttribute attribute,
int index,
Object value)
Adds the
value at the index in the content of the attribute of the object . |
protected void |
addReference(PersistentEObject object,
EReference reference,
int index,
PersistentEObject referencedObject)
Adds the
value at the index in the content of the reference of the object . |
void |
clear(InternalEObject internalObject,
EStructuralFeature feature)
Removes all values form the
content of the object's feature |
boolean |
contains(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns whether the
content of the object's feature contains the given value. |
EObject |
eObject(Id id)
|
protected Object |
getAttribute(PersistentEObject object,
EAttribute attribute,
int index)
Returns the value at the
index in the content of the attribute of the object . |
InternalEObject |
getContainer(InternalEObject internalObject)
Returns the object's
container . |
EStructuralFeature |
getContainingFeature(InternalEObject internalObject)
Returns the object's
containing feature . |
protected Object |
getFromTable(PersistentEObject object,
EStructuralFeature feature)
|
protected Object |
getReference(PersistentEObject object,
EReference reference,
int index)
Returns the value at the
index in the content of the reference of the object . |
int |
indexOf(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns the first index of the given value in the
content of the object's feature. |
protected Table |
initTable(Connection connection,
TableName tableName,
Admin admin)
Initialize the HBase table by creating the columns and column families to store the model.
|
boolean |
isSet(InternalEObject internalObject,
EStructuralFeature feature)
Returns whether the object's feature is considered set.
|
int |
lastIndexOf(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns the last index of the given value in the
content of the object's feature. |
protected Object |
removeAttribute(PersistentEObject object,
EAttribute attribute,
int index)
Removes the value at the
index in the content of the attribute of the object . |
protected Object |
removeReference(PersistentEObject object,
EReference reference,
int index)
Removes the value at the
index in the content of the reference of the object . |
void |
save()
Saves the modifications of the owned
EObject s in the persistence back-end. |
protected Object |
setAttribute(PersistentEObject object,
EAttribute attribute,
int index,
Object value)
Sets the value at the
index in the content of the attribute of the object . |
protected Object |
setReference(PersistentEObject object,
EReference reference,
int index,
PersistentEObject referencedObject)
Sets the value at the
index in the content of the reference of the object . |
int |
size(InternalEObject internalObject,
EStructuralFeature feature)
Returns the number of values in the
content of the object's feature. |
void |
unset(InternalEObject internalObject,
EStructuralFeature feature)
Unsets the feature of the object.
|
protected void |
updateContainment(PersistentEObject object,
EReference reference,
PersistentEObject referencedObject)
Add
referencedObject in the reference containment list of object . |
protected void |
updateInstanceOf(PersistentEObject object)
Computes
object 's metaclass information and persists them in the database. |
add, clearAttribute, clearReference, containsAttribute, containsReference, create, get, hashCode, indexOfAttribute, indexOfReference, isEmpty, isSetAttribute, isSetReference, lastIndexOfAttribute, lastIndexOfReference, move, parseProperty, remove, resource, serializeToProperty, set, toArray, toArray, unsetAttribute, unsetReference
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllInstances
protected static final byte[] PROPERTY_FAMILY
protected static final int DEFAULT_CACHE_SIZE
protected Table table
public DirectWriteHBaseStore(Resource.Internal resource) throws IOException
DirectWriteHBaseStore
on the given resource
.resource
- the resource to persist and accessIOException
- if the HBase server cannot be foundprotected Table initTable(Connection connection, TableName tableName, Admin admin) throws IOException
connection
- the connection to the HBase servertableName
- the name of the table to access on the serveradmin
- the administrator client of the HBase serverIOException
- if the HBase server cannot be foundpublic int size(InternalEObject internalObject, EStructuralFeature feature)
org.eclipse.emf.ecore.InternalEObject.EStore
content
of the object's feature.internalObject
- the object in question.feature
- a many-valued
feature of the object.public InternalEObject getContainer(InternalEObject internalObject)
org.eclipse.emf.ecore.InternalEObject.EStore
container
.EObject.eContainer()
public EStructuralFeature getContainingFeature(InternalEObject internalObject)
org.eclipse.emf.ecore.InternalEObject.EStore
containing feature
.EObject.eContainingFeature()
public EObject eObject(Id id)
PersistentStore
protected void updateContainment(PersistentEObject object, EReference reference, PersistentEObject referencedObject)
referencedObject
in the reference
containment list of object
. Inverse container
feature between referencedObject
and object
is also updated.object
- the container elementreference
- the containment EReference
referencedObject
- the element to add to object
's containment listprotected void updateInstanceOf(PersistentEObject object)
object
's metaclass information and persists them in the database.object
- the PersistentEObject
to persist the metaclass ofprotected Object getFromTable(PersistentEObject object, EStructuralFeature feature)
object
- the source elementfeature
- the EStructuralFeature
to get the value offeature
. It can be a String
for single-valued EStructuralFeature
s or a String
[] for many-valued EStructuralFeature
spublic void save()
PersistentStore
EObject
s in the persistence back-end.save
in interface PersistentStore
save
in class AbstractDirectWriteStore<HBasePersistenceBackend>
public boolean isSet(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStore
By default, calls the associated methods depending on the type of the feature
.
isSet
in interface InternalEObject.EStore
isSet
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a feature of the object.true
if the object's feature is considered set.AbstractDirectWriteStore.isSetAttribute(PersistentEObject, EAttribute)
,
AbstractDirectWriteStore.isSetReference(PersistentEObject, EReference)
public void unset(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStore
By default, calls the associated methods depending on the type of the feature
.
unset
in interface InternalEObject.EStore
unset
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a feature of the object.AbstractDirectWriteStore.unsetAttribute(PersistentEObject, EAttribute)
,
AbstractDirectWriteStore.unsetReference(PersistentEObject, EReference)
public boolean contains(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStore
content
of the object's feature contains the given value.
By default, calls the associated methods depending on the type of the feature
.
contains
in interface InternalEObject.EStore
contains
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a many-valued
feature of the object.value
- the value in question.true
if the content of the object's feature contains the given value.AbstractDirectWriteStore.containsAttribute(PersistentEObject, EAttribute, Object)
,
AbstractDirectWriteStore.containsReference(PersistentEObject, EReference, PersistentEObject)
public int indexOf(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStore
content
of the object's feature.
By default, calls the associated methods depending on the type of the feature
.
indexOf
in interface InternalEObject.EStore
indexOf
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a many-valued
feature of the object.value
- the value in question.AbstractDirectWriteStore.indexOfAttribute(PersistentEObject, EAttribute, Object)
,
AbstractDirectWriteStore.indexOfReference(PersistentEObject, EReference, PersistentEObject)
public int lastIndexOf(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStore
content
of the object's feature.
By default, calls the associated methods depending on the type of the feature
.
lastIndexOf
in interface InternalEObject.EStore
lastIndexOf
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a many-valued
feature of the object.value
- the value in question.AbstractDirectWriteStore.lastIndexOfAttribute(PersistentEObject, EAttribute, Object)
,
AbstractDirectWriteStore.lastIndexOfReference(PersistentEObject, EReference, PersistentEObject)
public void clear(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStore
content
of the object's feature
By default, calls the associated methods depending on the type of the feature
.
clear
in interface InternalEObject.EStore
clear
in class AbstractDirectWriteStore<HBasePersistenceBackend>
internalObject
- the object in question.feature
- a many-valued
feature of the object.AbstractDirectWriteStore.clearAttribute(PersistentEObject, EAttribute)
,
AbstractDirectWriteStore.clearReference(PersistentEObject, EReference)
protected Object getAttribute(PersistentEObject object, EAttribute attribute, int index)
AbstractDirectWriteStore
index
in the content of the attribute
of the object
.getAttribute
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectattribute
- an attribute of the object
index
- an index within the content or PersistentStore.NO_INDEX
AbstractDirectWriteStore.get(InternalEObject, EStructuralFeature, int)
protected Object getReference(PersistentEObject object, EReference reference, int index)
AbstractDirectWriteStore
index
in the content of the reference
of the object
.getReference
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectreference
- a reference of the object
index
- an index within the content or PersistentStore.NO_INDEX
AbstractDirectWriteStore.get(InternalEObject, EStructuralFeature, int)
protected Object setAttribute(PersistentEObject object, EAttribute attribute, int index, Object value)
AbstractDirectWriteStore
index
in the content of the attribute
of the object
.setAttribute
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectattribute
- an attribute of the object
index
- an index within the content or PersistentStore.NO_INDEX
value
- the new valueAbstractDirectWriteStore.set(InternalEObject, EStructuralFeature, int, Object)
protected Object setReference(PersistentEObject object, EReference reference, int index, PersistentEObject referencedObject)
AbstractDirectWriteStore
index
in the content of the reference
of the object
.setReference
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectreference
- a reference of the object
index
- an index within the content or PersistentStore.NO_INDEX
referencedObject
- the new valueAbstractDirectWriteStore.set(InternalEObject, EStructuralFeature, int, Object)
protected void addAttribute(PersistentEObject object, EAttribute attribute, int index, Object value)
AbstractDirectWriteStore
value
at the index
in the content of the attribute
of the object
.addAttribute
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectattribute
- a many-valued attribute of the object
index
- an index within the contentvalue
- the value to addAbstractDirectWriteStore.add(InternalEObject, EStructuralFeature, int, Object)
protected void addReference(PersistentEObject object, EReference reference, int index, PersistentEObject referencedObject)
AbstractDirectWriteStore
value
at the index
in the content of the reference
of the object
.addReference
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectreference
- a many-valued reference of the object
index
- an index within the contentreferencedObject
- the value to addAbstractDirectWriteStore.add(InternalEObject, EStructuralFeature, int, Object)
protected Object removeAttribute(PersistentEObject object, EAttribute attribute, int index)
AbstractDirectWriteStore
index
in the content of the attribute
of the object
.removeAttribute
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectattribute
- a many-valued attribute of the object
index
- the index within the content of the value to removeAbstractDirectWriteStore.remove(InternalEObject, EStructuralFeature, int)
protected Object removeReference(PersistentEObject object, EReference reference, int index)
AbstractDirectWriteStore
index
in the content of the reference
of the object
.removeReference
in class AbstractDirectWriteStore<HBasePersistenceBackend>
object
- the objectreference
- a many-valued reference of the object
index
- the index within the content of the value to removeAbstractDirectWriteStore.remove(InternalEObject, EStructuralFeature, int)
Copyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.