java.lang.Object
de.grogra.xl.impl.base.Graph
This class is an abstract base class for implementations of
XL's runtime model for graph-like structures.
Graph
represents a single graph on which XL's query statements
may operate.
The package documentation contains more information about the structure of the graph that is implied by this base class.
The current derivation mode for rule applications acting on this graph
is set by setDerivationMode(int)
and may be truly parallel
(PARALLEL_MODE
), parallel and non-deterministic
(PARALLEL_NON_DETERMINISTIC_MODE
, one application is chosen
out of several applications which delete the same node),
sequential (SEQUENTIAL_MODE
, only the first rule application
per derivation step is used), or sequential and non-deterministic
(SEQUENTIAL_NON_DETERMINISTIC_MODE
, only one rule application
per derivation step is used).
- Author:
- Ole Kniemeyer
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Bit mask forgetDerivationMode()
which indicates that nodes which were already deleted by previous rule applications of the current derivation step shall be excluded from further matches of the same step.static final int
Bit mask forgetDerivationMode()
which indicates that rules have to be applied as interpretive rules.static final int
Mask forgetDerivationMode()
to obtain the mode part (one ofPARALLEL_MODE
,PARALLEL_NON_DETERMINISTIC_MODE
,SEQUENTIAL_MODE
,SEQUENTIAL_NON_DETERMINISTIC_MODE
).static final int
Bit mask forgetDerivationMode()
indicating a true parallel derivation mode.static final int
Bit mask forgetDerivationMode()
indicating a parallel non-deterministic derivation mode.static final int
Bit mask forgetDerivationMode()
indicating a sequential derivation mode.static final int
Bit mask forgetDerivationMode()
indicating a sequential derivation mode. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allowNoninjectiveMatchesByDefault
(boolean value) void
allowNoninjectiveMatchesForNextQuery
(boolean value) Deprecated.boolean
areComparableScales
(Object nodeA, Object nodeB) protected abstract void
boolean
canEnumerateNodes
(Type type) Can nodes of the specifiedtype
be enumerated?protected abstract void
createMatcher
(Pattern pred, XBitSet providedConstants, IntList neededConstantsOut) Creates a query state to be used for queries which use this graph.protected abstract GraphQueue
createQueue
(QueueCollection qc, QueueDescriptor descr) protected Graph.ThreadData
long
derive()
void
enumerateEdges
(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) void
enumerateSpaces
(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) Searches the graph (with reference to the type graph) for matching multiscale patternsint
Returns the current derivation mode.int
getMinimumEncoarseDepthDiff
(Object coarseNode, Object fineNode) Returns the length of the shortest encoarsement path from fineNode to coarseNodegetModel()
Returns this graph's run-time model.protected Object
getPredecessor
(Object node) int
getScaleValue
(HashMap<Object, Integer> sortedTypeGraph, Object node) protected Graph.ThreadData
getTypeNode
(Type t) getTypeNode
(Object node) Get node in type graph representing the type of the input nodeboolean
isInTypeGraph
(Object node) Check if a node is in the type graphboolean
isSameScale
(Object nodeA, Object nodeB) Checks if 2 nodes are in the same scale in the type graph.void
setDerivationMode
(int mode) Sets the current derivation mode.Returns the ordered scale values of the nodes in the type graphMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.grogra.xl.query.Graph
canEnumerateEdges, createProducer, enumerateNodes, getRoot, getTypeRoot
-
Field Details
-
PARALLEL_MODE
public static final int PARALLEL_MODEBit mask forgetDerivationMode()
indicating a true parallel derivation mode. All rules are applied via every possible match in parallel. A single node may be deleted by several rule applications.- See Also:
-
PARALLEL_NON_DETERMINISTIC_MODE
public static final int PARALLEL_NON_DETERMINISTIC_MODEBit mask forgetDerivationMode()
indicating a parallel non-deterministic derivation mode. It is ensured that a single node is deleted by at most one actual rule application. If several potential rule applications delete the same node, one actual application is chosen pseudo-randomly.- See Also:
-
SEQUENTIAL_MODE
public static final int SEQUENTIAL_MODEBit mask forgetDerivationMode()
indicating a sequential derivation mode. Only one rule application is performed in a single step (as marked byderive()
). If several applications are possible, only the first one is chosen.- See Also:
-
SEQUENTIAL_NON_DETERMINISTIC_MODE
public static final int SEQUENTIAL_NON_DETERMINISTIC_MODEBit mask forgetDerivationMode()
indicating a sequential derivation mode. Only one rule application is performed in a single step (as marked byderive()
). If several applications are possible, one is chosen pseudo-randomly.- See Also:
-
MODE_MASK
public static final int MODE_MASKMask forgetDerivationMode()
to obtain the mode part (one ofPARALLEL_MODE
,PARALLEL_NON_DETERMINISTIC_MODE
,SEQUENTIAL_MODE
,SEQUENTIAL_NON_DETERMINISTIC_MODE
).- See Also:
-
INTERPRETIVE_FLAG
public static final int INTERPRETIVE_FLAGBit mask forgetDerivationMode()
which indicates that rules have to be applied as interpretive rules.- See Also:
-
EXCLUDE_DELETED_FLAG
public static final int EXCLUDE_DELETED_FLAGBit mask forgetDerivationMode()
which indicates that nodes which were already deleted by previous rule applications of the current derivation step shall be excluded from further matches of the same step.- See Also:
-
-
Constructor Details
-
Graph
-
-
Method Details
-
getThreadData
-
createThreadData
-
getModel
Description copied from interface:Graph
Returns this graph's run-time model. -
createQueue
-
createQueryState
Description copied from interface:Graph
Creates a query state to be used for queries which use this graph. The returned query state has to be an instance of the type defined byCompiletimeModel.getQueryStateType()
of the corresponding compile-time model.- Specified by:
createQueryState
in interfaceGraph
- Returns:
- a new query state
-
allowNoninjectiveMatchesByDefault
public void allowNoninjectiveMatchesByDefault(boolean value) -
allowNoninjectiveMatchesForNextQuery
Deprecated. -
getDerivationMode
public int getDerivationMode()Returns the current derivation mode. This is a combination of one of the bit masksPARALLEL_MODE
,PARALLEL_NON_DETERMINISTIC_MODE
,SEQUENTIAL_MODE
,SEQUENTIAL_NON_DETERMINISTIC_MODE
with the flagsINTERPRETIVE_FLAG
andEXCLUDE_DELETED_FLAG
.- Returns:
- current derivation mode
- See Also:
-
setDerivationMode
public void setDerivationMode(int mode) Sets the current derivation mode.mode
is a combination of the bit masksPARALLEL_MODE
,PARALLEL_NON_DETERMINISTIC_MODE
,SEQUENTIAL_MODE
,SEQUENTIAL_NON_DETERMINISTIC_MODE
with the flagsINTERPRETIVE_FLAG
andEXCLUDE_DELETED_FLAG
.- Parameters:
mode
- desired derivation mode- See Also:
-
derive
public long derive() -
beginModifications
protected abstract void beginModifications() -
commitModifications
protected abstract void commitModifications() -
getQueues
-
canEnumerateNodes
Description copied from interface:Graph
Can nodes of the specifiedtype
be enumerated? This method returnstrue
iff this graph can enumerate nodes of the giventype
using the methodGraph.enumerateNodes(de.grogra.reflect.Type, de.grogra.xl.query.QueryState, int, de.grogra.xl.query.MatchConsumer, int)
.- Specified by:
canEnumerateNodes
in interfaceGraph
- Parameters:
type
- the type of nodes- Returns:
true
iff nodes oftype
can be enumerated
-
enumerateEdges
public void enumerateEdges(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) - Specified by:
enumerateEdges
in interfaceGraph
-
getPredecessor
-
createMatcher
public Pattern.Matcher createMatcher(Pattern pred, XBitSet providedConstants, IntList neededConstantsOut) - Specified by:
createMatcher
in interfaceGraph
-
enumerateSpaces
public void enumerateSpaces(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) Searches the graph (with reference to the type graph) for matching multiscale patterns- Specified by:
enumerateSpaces
in interfaceGraph
- Parameters:
node
- node already bound before this spacingdir
- edge directionedgeType
- class type of edge, normally intqs
- QueryState instancepattern
- edge pattern, i.e. successor, branching, refinement, etc.consumer
- CompoundPattern instance for continuing match logic
-
isInTypeGraph
Check if a node is in the type graph- Parameters:
node
-- Returns:
- true if input node is part of the type graph, false otherwise
-
sortedTypeGraph
Description copied from interface:Graph
Returns the ordered scale values of the nodes in the type graph- Specified by:
sortedTypeGraph
in interfaceGraph
- Returns:
- HashMap instance containing mappings from the type graph nodes to scale values
-
getScaleValue
-
getTypeNode
-
getTypeNode
Get node in type graph representing the type of the input node- Parameters:
node
-- Returns:
- node from type graph representing type of input node
-
areComparableScales
-
isSameScale
Checks if 2 nodes are in the same scale in the type graph.- Parameters:
nodeA
-nodeB
-- Returns:
-
getMinimumEncoarseDepthDiff
Returns the length of the shortest encoarsement path from fineNode to coarseNode- Parameters:
coarseNode
-fineNode
-- Returns:
- length of path, 0 if coarseNode is not encoarsement of fineNode, -1 if error
-