VS
- The generic type for the per-vertex state. This is scoped to the
computation of the IGASProgram
.ES
- The generic type for the per-edge state. This is scoped to the
computation of the IGASProgram
.ST
- The generic type for the SUM. This is often directly related to
the generic type for the per-edge state, but that is not always
true. The SUM type is scoped to the GATHER + SUM operation (NOT
the computation).public interface IGASProgram<VS,ES,ST> extends IGASOptions<VS,ES,ST>, IBindingExtractor<VS,ES,ST>
Modifier and Type | Method and Description |
---|---|
VS |
apply(IGASState<VS,ES,ST> state,
org.openrdf.model.Value u,
ST sum)
Apply the reduced aggregation computed by GATHER + SUM to the vertex.
|
void |
before(IGASContext<VS,ES,ST> ctx)
One time initialization before the
IGASProgram is executed. |
ST |
gather(IGASState<VS,ES,ST> state,
org.openrdf.model.Value u,
org.openrdf.model.Statement e)
GATHER is a map/reduce over the edges of the vertex.
|
void |
initVertex(IGASContext<VS,ES,ST> ctx,
IGASState<VS,ES,ST> state,
org.openrdf.model.Value u)
Callback to initialize the state for each vertex in the initial frontier
before the first iteration.
|
boolean |
isChanged(IGASState<VS,ES,ST> state,
org.openrdf.model.Value u)
Return
true iff the vertex should run its SCATTER phase. |
boolean |
nextRound(IGASContext<VS,ES,ST> ctx)
Return
true iff the algorithm should continue. |
void |
scatter(IGASState<VS,ES,ST> state,
IGASScheduler sch,
org.openrdf.model.Value u,
org.openrdf.model.Statement e) |
ST |
sum(IGASState<VS,ES,ST> state,
ST left,
ST right)
SUM is a pair-wise reduction that is applied during the GATHER.
|
getEdgeStateFactory, getGatherEdges, getInitialFrontierEnum, getSampleEdgesFilter, getScatterEdges, getVertexStateFactory
getBinderList
void before(IGASContext<VS,ES,ST> ctx)
IGASProgram
is executed.ctx
- The evaluation context.void initVertex(IGASContext<VS,ES,ST> ctx, IGASState<VS,ES,ST> state, org.openrdf.model.Value u)
u
- The vertex.
TODO We do not need both the IGASContext
and the
IGASState
. The latter is available from the former.ST gather(IGASState<VS,ES,ST> state, org.openrdf.model.Value u, org.openrdf.model.Statement e)
u
- The vertex for which the gather is being performed. The gather
will be invoked for each edge indident on u
(as
specified by IGASOptions.getGatherEdges()
).e
- An edge (s,p,o).Note: by lazily resolving the vertex and/or edge state in the GAS callback methods we avoid eagerly materializing data that we do not need. [Lazy resolution does not work on a cluster. The only available semantics there are lazy resolution of state that was materialized in order to support a gather() or scatter() for a vertex.]
Note: The state associated with the source/target vertex and the edge should all be immutable for the GATHER. The vertex state should only be mutable for the APPLY(). The target vertex state and/or edge state MAY be mutable for the SCATTER, but that depends on the algorithm. How can we get these constraints into the API?
ST sum(IGASState<VS,ES,ST> state, ST left, ST right)
left
- An edge state accumulant.right
- Another edge state accumulant.Value
implementation of the backend. E.g., Value versus IV.VS apply(IGASState<VS,ES,ST> state, org.openrdf.model.Value u, ST sum)
u
- The vertex.sum
- The aggregated accumulate across the edges as computed by
GATHER and SUM -or- null
if there is no
accumulant (this will happen if the GATHER did not find any
edges to visit).boolean isChanged(IGASState<VS,ES,ST> state, org.openrdf.model.Value u)
true
iff the vertex should run its SCATTER phase.
This may be used to avoid visiting the edges if it is known (e.g., based
on the APPLY) that the vertex has not changed. This can save a
substantial amount of effort.state
- u
- The vertex.void scatter(IGASState<VS,ES,ST> state, IGASScheduler sch, org.openrdf.model.Value u, org.openrdf.model.Statement e)
state
- u
- The vertex for which the scatter will being performed.e
- The edge.boolean nextRound(IGASContext<VS,ES,ST> ctx)
true
iff the algorithm should continue. This is
invoked after every iteration, once the new frontier has been computed
and IGASState.round()
has been advanced. An implementation may
simply return true
, in which case the algorithm will
continue IFF the current frontier is not empty.
Note: While this can be used to make custom decisions concerning the
halting criteria, it can also be used as an opportunity to handshake with
a custom IGraphAccessor
in order to process a dynamic graph.
ctx
- The evaluation context.true
if the algorithm should continue (as long as
the frontier is non-empty).Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.