public class GASState<VS,ES,ST> extends Object implements IGASState<VS,ES,ST>
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<org.openrdf.model.Statement,ES> |
edgeState
TODO EDGE STATE: state needs to be configurable.
|
protected ConcurrentMap<org.openrdf.model.Value,VS> |
vertexState
The state associated with each visited vertex.
|
Constructor and Description |
---|
GASState(IGASEngine gasEngine,
IGraphAccessor graphAccessor,
IStaticFrontier frontier,
IGASSchedulerImpl gasScheduler,
IGASProgram<VS,ES,ST> gasProgram) |
Modifier and Type | Method and Description |
---|---|
org.openrdf.model.Value |
asValue(org.openrdf.model.Value value)
Convert a value into an appropriate internal form.
|
int |
compareTo(org.openrdf.model.Value u,
org.openrdf.model.Value v)
Return -1, o, or 1 if
u is LT, EQ, or GT v . |
org.openrdf.model.Statement |
decodeStatement(org.openrdf.model.Value v)
If the vertex is actually an edge, then return the decoded edge.
|
void |
endRound()
End the current round, advance the round counter, and compact the new
frontier.
|
IStaticFrontier |
frontier()
The current frontier.
|
protected IGraphAccessor |
getGraphAccessor()
Provides access to the backing graph.
|
org.openrdf.model.Literal |
getLinkAttr(org.openrdf.model.Value u,
org.openrdf.model.Statement e)
This will only work for the BigdataGASState.
|
org.openrdf.model.Value |
getOtherVertex(org.openrdf.model.Value u,
org.openrdf.model.Statement e)
Return the other end of a link.
|
IGASSchedulerImpl |
getScheduler()
Return the
IGASSchedulerImpl . |
ES |
getState(org.openrdf.model.Statement e)
Get the state for the edge using the appropriate factory.
|
VS |
getState(org.openrdf.model.Value v)
Get the state for the vertex using the appropriate factory.
|
boolean |
isAttrib(org.openrdf.model.Statement e)
Return
true iff the given Statement models an
property value for a vertex of the graph (Statement s also model
edges). |
boolean |
isEdge(org.openrdf.model.Statement e)
Return
true iff the given Statement models an edge
that connects two vertices (Statement s also model property
values). |
boolean |
isLinkAttrib(org.openrdf.model.Statement e,
org.openrdf.model.URI linkAttribType)
Return
true iff the statement models a link attribute having
the specified link type. |
boolean |
isVisited(Set<org.openrdf.model.Value> v)
Return
true iff the specified vertices all have an associated
vertex state object - this is interpreted as meaning that the vertex has
been "visited". |
boolean |
isVisited(org.openrdf.model.Value v)
Return
true iff the specified vertex has an associated
vertex state object - this is interpreted as meaning that the vertex has
been "visited". |
<T> T |
reduce(IReducer<VS,ES,ST,T> op)
Compute a reduction over the vertex state table (all vertices that have
had their vertex state materialized).
|
void |
reset()
Discard computation state (the frontier, vertex state, and edge state)
and reset the round counter.
|
void |
retainAll(Set<org.openrdf.model.Value> retainSet)
Retain only those vertices in the visited set that are found in the
specified collection.
|
int |
round()
Return the current evaluation round (origin ZERO).
|
void |
setFrontier(IGASContext<VS,ES,ST> ctx,
org.openrdf.model.Value... vertices)
IGASState.reset() the computation state and populate the initial frontier. |
String |
toString(org.openrdf.model.Statement e)
Return a useful representation of an edge (non-batch API, debug only).
|
void |
traceState()
Conditionally log various interesting information about the state of the
computation.
|
protected final ConcurrentMap<org.openrdf.model.Value,VS> vertexState
protected final ConcurrentMap<org.openrdf.model.Statement,ES> edgeState
null
.public GASState(IGASEngine gasEngine, IGraphAccessor graphAccessor, IStaticFrontier frontier, IGASSchedulerImpl gasScheduler, IGASProgram<VS,ES,ST> gasProgram)
protected IGraphAccessor getGraphAccessor()
traceState()
.public IStaticFrontier frontier()
IGASState
public IGASSchedulerImpl getScheduler()
IGASState
IGASSchedulerImpl
.getScheduler
in interface IGASState<VS,ES,ST>
public VS getState(org.openrdf.model.Value v)
IGASState
public boolean isVisited(org.openrdf.model.Value v)
IGASState
true
iff the specified vertex has an associated
vertex state object - this is interpreted as meaning that the vertex has
been "visited".public boolean isVisited(Set<org.openrdf.model.Value> v)
IGASState
true
iff the specified vertices all have an associated
vertex state object - this is interpreted as meaning that the vertex has
been "visited".public ES getState(org.openrdf.model.Statement e)
IGASState
public void retainAll(Set<org.openrdf.model.Value> retainSet)
IGASState
public int round()
IGASState
public void reset()
IGASState
Note: The graph is NOT part of the computation and is not discared by this method.
public void setFrontier(IGASContext<VS,ES,ST> ctx, org.openrdf.model.Value... vertices)
IGASState
IGASState.reset()
the computation state and populate the initial frontier.setFrontier
in interface IGASState<VS,ES,ST>
ctx
- The execution context.vertices
- One or more vertices that will be included in the initial
frontier.public void traceState()
IGASState
traceState
in interface IGASState<VS,ES,ST>
public void endRound()
IGASState
public <T> T reduce(IReducer<VS,ES,ST,T> op)
Note: We can not do a parallel reduction right now because the backing
class does not expose a parallel iterator, e.g., a segment-wise iterator.
The reduction over the vertexState
is quite slow as a result.
It looks like bulk parallel operators will be eventually introduced into the Java concurrency collections. For now, it seems like the short term solution would be to drop them onto stripped lists at the same time that they are first inserted into the CHM. I could then read over those striped lists in parallel during the reduction.
The IReducer should run with parallel threads. This is a huge serial bottleneck right now. Fixing this will require a data structure with a parallel iterator, not the CHM. See http://stackoverflow.com/questions/20164690 /using-scalas-parhashmap-in-javas-project-instead-of-concurrenthashmap
It seems like the short term solution would be to drop them onto striped lists at the same time that they are first inserted into the CHM. I could then read over those striped lists in parallel during the reduction.
public String toString(org.openrdf.model.Statement e)
IGASState
Value
s. In this case, it
will materialize the RDF Values and present a pleasant view of the edge.
The materialization step is a random access, which is why this method is
for debug only. Efficient, vectored mechanisms exist to materialize RDF
Value
s for other purposes, e.g., when exporting a set of edges as
as graph in a standard interchange syntax.public org.openrdf.model.Value getOtherVertex(org.openrdf.model.Value u, org.openrdf.model.Statement e)
FIXME We can optimize this to use reference testing if we are careful in
the GATHER and SCATTER implementations to impose a canonical mapping over
the vertex objects for the edges that are exposed to the
IGASProgram
during a single round.
getOtherVertex
in interface IGASState<VS,ES,ST>
u
- One end of the link.e
- The link.public org.openrdf.model.Literal getLinkAttr(org.openrdf.model.Value u, org.openrdf.model.Statement e)
getLinkAttr
in interface IGASState<VS,ES,ST>
u
- One end of the link.e
- The link.public boolean isEdge(org.openrdf.model.Statement e)
IGASState
true
iff the given Statement
models an edge
that connects two vertices (Statement
s also model property
values).public boolean isAttrib(org.openrdf.model.Statement e)
IGASState
true
iff the given Statement
models an
property value for a vertex of the graph (Statement
s also model
edges).public boolean isLinkAttrib(org.openrdf.model.Statement e, org.openrdf.model.URI linkAttribType)
true
iff the statement models a link attribute having
the specified link type. When this method returns true
, the
Statement.getSubject()
may be decoded to obtain the link
described by that link attribute using IGASState.decodeStatement(Value)
.
The openrdf implementation does not support link attributes and this
method always returns false
.
isLinkAttrib
in interface IGASState<VS,ES,ST>
e
- The statement.linkAttribType
- The type for the link attribute.false
public org.openrdf.model.Statement decodeStatement(org.openrdf.model.Value v)
Note: A vertex may be an edge. A link attribute is modeled by treating the link as a vertex and then asserting a property value about that "link vertex". For bigdata, this is handled efficiently as inline statements about statements. This approach subsumes the property graph model (property graphs do not permit recursive nesting of these relationships) and is 100% consistent with RDF reification, except that the link attributes are modeled efficiently inline with the links. This is what we call Reification Done Right .
The openrdf implementation does not support link attributes and this
method always returns null
.
decodeStatement
in interface IGASState<VS,ES,ST>
v
- The vertex.null
public int compareTo(org.openrdf.model.Value u, org.openrdf.model.Value v)
IGASState
u
is LT, EQ, or GT v
. A
number of GAS programs depend on the ability to place an order over the
vertex identifiers, as does 2D partitioning. The ordering provided by
this method MAY be arbitrary, but it MUST be total and stable across the
life-cycle of the GAS program evaluation.public org.openrdf.model.Value asValue(org.openrdf.model.Value value)
IGASState
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.