public class RuleStats extends Object
IStep
did when it was executed.
Program execution has the general form of either a set of IStep
s
executed, at least logically, in parallel, or a sequence of IStep
s
executed in sequence. An IStep
may be a closure operation of one or
more IRule
s, even when it is the top-level IStep
. Inside of
a closure operation, there are one or more rounds and each rule in the
closure will be run in each round. There is no implicit order on the rules
within a closure operation, but they may be forced to execute in a sequence
if the total program execution context forces sequential execution.
In order to aggregate the data on rule execution, we want to roll up the data for the individual rules along the same lines as the program structure.
Modifier and Type | Field and Description |
---|---|
long[] |
chunkCount
The #of chunks materialized for each predicate in the body of the rule
(in the order in which they were declared, not the order in which they
were evaluated).
|
int |
closureRound
The round is zero unless this is a closure operations and then it is an
integer in [1:nrounds].
|
List<RuleStats> |
detailStats
|
long |
elapsed
Time to compute the entailments (ms).
|
long[] |
elementCount
The #of elements considered for each predicate in the body of the rule
(in the order in which they were declared, not the order in which they
were evaluated).
|
int[] |
evalOrder
The order of execution of the predicates in the body of a rule (only
available at the detail level of a single rule instance execution).
|
IKeyOrder[] |
keyOrder
An array of the
IKeyOrder that was used for each predicate in the
tail of the rule. |
AtomicLong |
mutationCount
The #of elements that were actually added to (or removed from) the
relation indices.
|
String |
name
The name of the rule.
|
int[] |
nvars
The #of unbound variables for the predicates in the tail of the
Rule (only available at the detail level of a single rule
instance execution). |
int[] |
permutation
|
long[] |
rangeCount
The predicated range counts for each predicate in the body of the rule
(in the order in which they were declared, not the order in which they
were evaluated) as reported by the
IRangeCountFactory . |
IStep |
rule
The
IStep that was executed. |
AtomicLong |
solutionCount
The #of
ISolution s computed by the rule regardless of whether or
not they are written onto an IMutableRelation and regardless of
whether or not they duplicate a solution already computed. |
long |
startTime
The start time for the rule execution.
|
int[] |
subqueryCount
The #of subqueries examined for each predicate in the rule (in the order
in which they were declared, not the order in which they were evaluated).
|
Constructor and Description |
---|
RuleStats(IRuleState ruleState)
Initializes statistics from an
iRule and its
IEvaluationPlan . |
RuleStats(IStep step)
Initializes statistics for an
IStep . |
Modifier and Type | Method and Description |
---|---|
void |
add(RuleStats o)
Aggregates statistics.
|
String |
getHeadings()
Returns the headings.
|
String |
toString()
Reports aggregate and details.
|
protected String |
toString(IPredicate pred)
Return a human readable representation of the predicate.
|
String |
toString(long minElapsed,
boolean joinDetails) |
String |
toStringSimple(int depth,
boolean titles,
boolean joinDetails)
Reports just the data for this record.
|
public final String name
public int closureRound
public AtomicLong solutionCount
ISolution
s computed by the rule regardless of whether or
not they are written onto an IMutableRelation
and regardless of
whether or not they duplicate a solution already computed.
Note: this counter will be larger than the actual #of solutions generated
when evaluating an ISlice
since the pattern used is to invoke
AtomicLong.incrementAndGet()
and add the ISolution
to the
IBuffer
iff the post-increment value is LT
ISlice.getLast()
. Since we are working with the post-increment
value when handling an ISlice
this is naturally one larger than
the #of ISolution
s actually added to the IBuffer
if we
halt processing because we have reached the limit on the ISlice
.
public AtomicLong mutationCount
IMutableRelation
API. Correct reporting by that API and correct aggregation here are
critical to the correct termination of the fix point of some rule set.
Note: This value is ONLY incremented when the IBuffer
is flushed.
Note: Each IRule
will have its own RuleStats
on which it
reports its mutation count. However, since evaluation of IRule
s
MAY proceed in parallel and since multiple IRule
s can write on
the same IBuffer
, the mutation counts can not be credited
unambiguously to any given rule when rules run in parallel.
Note: IBuffer.flush()
maintains a running mutationCount.
Therefore only the end state of that counter should be set on
mutationCount
. Otherwise the reported mutationCount
may overreport the actual mutation count.
add(RuleStats)
public final long startTime
RuleStats
instance is created). The
startTime is mainly intended for use when correlating collected
performance counters with query execution.public long elapsed
public final int[] nvars
Rule
(only available at the detail level of a single rule
instance execution). The array is correlated with the predicates index in
the tail of the rule NOT with its evaluation order.public final int[] evalOrder
evalOrder
will always contain zeros since it can
not be meaningfully combined across executions of either the same or
different rules.public final int[] permutation
public final IKeyOrder[] keyOrder
IKeyOrder
that was used for each predicate in the
tail of the rule. The array is correlated with the predicates index in
the tail of the rule NOT with its evaluation order.public final long[] rangeCount
IRangeCountFactory
. The range
counts are used by the IEvaluationPlan
. You can compare the
elementCount
s with the rangeCount
s to see the actual
vs predicated #of elements visited per predicate.public final long[] chunkCount
public final long[] elementCount
public final int[] subqueryCount
public RuleStats(IStep step)
IStep
.
Note: This form is used when statistics will be aggregated across the
execution of multiple IStep
s, such as when computing the closure
(fix point) of a set of IRule
s or a sequential IProgram
.
step
- The IStep
.public RuleStats(IRuleState ruleState)
iRule
and its
IEvaluationPlan
.
Note: This ctor variant makes available the order of execution and range
count metadata from the IEvaluationPlan
.
rule
- The IRule
.plan
- The IEvaluationPlan
.keyOrder
- Identifies which index will be used at each step in the
evaluation plan (the indices are correlated with the tail
predicate index, not the evaluation order index).public String getHeadings()
The following are present for every record.
IRule
execution
records. Each of these is an array containing one element per tail
predicate in the IRule
.
IKeyOrder
for the predicate(s) in the rule. Basically,
this tells you which index was used for each predicate.IRangeCountFactory
on behalf of the IEvaluationPlan
.joinDetails == true
was specified. Since the tail predicates
will be written into the table in this order, this information is mainly
of use if you want to resort the table while keeping the relationship
between the predicate evaluation order and the declared predicate order.joinDetails == true
was specified. When present, the tail
predicate details will be found on their own rows in the table and will
be aligned under the column whose details are being broken out.public String toStringSimple(int depth, boolean titles, boolean joinDetails)
depth
- The depth at which the record was encountered within some
top-level aggregation.titles
- When true
the titles will be displayed inline,
e.g., foo=12
vs 12
.joinDetails
- When true
, presents a tabular display of the
details for each JOIN IFF this RuleStats
was collected
for an IRule
(rather than an aggregation of
IRule
).protected String toString(IPredicate pred)
String.replace(CharSequence, CharSequence)
.pred
- A predicate from the tail of an IRule
.public String toString()
public String toString(long minElapsed, boolean joinDetails)
minElapsed
- The minimum elapsed time for which details will be shown.joinDetails
- When true
, also presents a tabular display of
the details for each JOIN in each IRule
.public void add(RuleStats o)
Note: since the mutation count as reported by each buffer is cumulative we DO NOT aggregate the mutation counts from sub-steps as it would cause double-counting when steps are executed in parallel.
Instead, once the total program is finished, the total mutation count is
computed as the value reported by IBuffer.flush()
for each buffer
on which the program writes.
o
- Statistics for another rule.ProgramTask.executeMutation(IStep)
,
MutationTask#flushBuffers(IJoinNexus, RuleStats, java.util.Map)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.