public final class SlotType extends Object implements HGCompositeType, HGSearchable<Slot,HGPersistentHandle>
The SlotType
handles atoms of type Slot
. Slots are used to
build up record types.
IMPLEMENTATION NOTE: Eventually, it will be useful to be able to search by slot name or slot value type only. To support this, it's probably best to create a separate index for each component. Also, index management should probably be updated once we have more flexible two-way indexes that represent a 1-1 mapping (so that a key may be efficiently searched by the value of the index entry); right now, removal of a slot is implemented by first constructing the Slot instance...(which is ok as long as this removal is not performed very often).
Modifier and Type | Field and Description |
---|---|
static String |
INDEX_NAME |
static String |
LABEL_DIMENSION |
static String |
VALUE_TYPE_DIMENSION |
Constructor and Description |
---|
SlotType() |
Modifier and Type | Method and Description |
---|---|
HGSearchResult<HGPersistentHandle> |
find(Slot key)
Returns a
HGSearchResult over all values matching a key in the
searched entity. |
Iterator<String> |
getDimensionNames()
Return an
Iterator listing the names of all
dimensions of this composite type. |
HGProjection |
getProjection(String dimensionName)
Get the projection function for a particular dimension.
|
Object |
make(HGPersistentHandle handle,
LazyRef<HGHandle[]> targetSet,
IncidenceSetRef incidenceSet)
Construct a new run-time instance of a hypergraph atom.
|
void |
release(HGPersistentHandle handle)
Release a hypergraph value instance from the persistent store.
|
void |
setHyperGraph(HyperGraph hg)
During load time, set the
HyperGraph
instance to which this atom belongs. |
HGPersistentHandle |
store(Object instance)
Store a run-time instance of a hypergraph atom into the hypergraph
HGStore
as a new atom. |
boolean |
subsumes(Object general,
Object specific)
A generic semantic predicate that returns
true if the first argument
is more general than the second. |
public static final String INDEX_NAME
public static final String LABEL_DIMENSION
public static final String VALUE_TYPE_DIMENSION
public void setHyperGraph(HyperGraph hg)
HGGraphHolder
During load time, set the HyperGraph
instance to which this atom belongs.
setHyperGraph
in interface HGGraphHolder
public Object make(HGPersistentHandle handle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet)
HGAtomType
Construct a new run-time instance of a hypergraph atom. A plain node must
be constructed whenever the targetSet
parameter is null or of
length 0. Otherwise, a HGLink
instance must be constructed.
It is not required that all atom types be able to construct both plain (node)
atoms and HGLink
s. It is up to an HGAtomType
implementation
to support either or both. When a HGLink
counterpart is not available
for a particular run-time type, an implementation may choose to create an instance
of the default link value holder implementation HGValuedLink
, provided
by HyperGraph.
make
in interface HGAtomType
handle
- The HGPersistentHandle
of the atom value.targetSet
- When the atom is a link, this parameter holds the target set of
the link. When the atom is a node, the parameter is an array of 0 length.incidenceSet
- A lazy reference to the set of links pointing to this atom. This is
null
if we are constructing an internal/nested value of some complex type.null
.
In case the handle
points to an invalid instance (inexisting or with
a erronous layout), the method should throw a HGException
.public HGPersistentHandle store(Object instance)
HGAtomType
Store a run-time instance of a hypergraph atom into the hypergraph HGStore
as a new atom.
store
in interface HGAtomType
instance
- The atom instance.public void release(HGPersistentHandle handle)
HGAtomType
Release a hypergraph value instance from the persistent store.
This method should be called when a HGPersistentHandle
returned from the store
is no longer in use.
release
in interface HGAtomType
handle
- The persistent handle of the value to release.public boolean subsumes(Object general, Object specific)
HGAtomType
A generic semantic predicate that returns true
if the first argument
is more general than the second. Atom types must implement this notion of specialization
whenever meaningful in the context of the entities being constructed.
The notion of subsumption can be seen as partial equivalence, or equivalence in one direction only.
As a relation, subsumtion is transitive and reflexive. The latter implies that, at a minimum,
the subsumes
method must return true
if
general.equals(specific)
.
subsumes
in interface HGAtomType
general
- The object which might be more general. Cannot be null
.specific
- The object which might be more specific. Cannot be null
.true if specific
can be used whenever general
is required and false
otherwise.
public HGSearchResult<HGPersistentHandle> find(Slot key)
HGSearchable
Returns a HGSearchResult
over all values matching a key in the
searched entity.
If there are no matches, the method should return HGSearchResult.EMPTY
. The
method will never return a null
. A HGException
may
be thrown in exceptional situations.
find
in interface HGSearchable<Slot,HGPersistentHandle>
public Iterator<String> getDimensionNames()
HGCompositeType
Return an Iterator
listing the names of all
dimensions of this composite type. A projection function can be obtained
through the getProjection
method.
getDimensionNames
in interface HGCompositeType
public HGProjection getProjection(String dimensionName)
HGCompositeType
Get the projection function for a particular dimension.
getProjection
in interface HGCompositeType
dimensionName
- The name of the dimension.HGProjection
instance.Copyright © 2015. All rights reserved.