Class ExtensibleDynamicEvaluationStatistics
- java.lang.Object
-
- org.eclipse.rdf4j.query.algebra.evaluation.impl.EvaluationStatistics
-
- org.eclipse.rdf4j.sail.extensiblestore.evaluationstatistics.ExtensibleEvaluationStatistics
-
- org.eclipse.rdf4j.sail.extensiblestore.evaluationstatistics.ExtensibleDynamicEvaluationStatistics
-
- All Implemented Interfaces:
DynamicStatistics
@Experimental public class ExtensibleDynamicEvaluationStatistics extends ExtensibleEvaluationStatistics implements DynamicStatistics
ExtensibleDynamicEvaluationStatistics aims to keep an internal estimate of the cardinality of various statement patterns.
It support getting the overall size, any single dimension cardinality (eg. ?a rdf:type ?b) and also two multidimensional patterns (:Peter rdf:type ?b; and ?a rdf:type foaf:Person).
Since evaluation statistics are best-effort, we use HLL as sets to keep the number of statements for each pattern we support. HLL is a very memory efficient set implementation. Furthermore we hash each pattern into a fixed bucket size, 1024 for single dimension and 64 per dimension for multidimensional patterns.
This means that adding ':peter rdf:type foaf:Person' and ':lisa rdf:type foaf:Person' could potentially return getCardinality(:peter, ?b, ?c) = 2 if both :peter and :lisa hash to the same of the 1024 buckets in subjectIndex.
HLL does not support "remove" operations, so there are two sets of every index. One for all added statements and one for all removed statements. If the user adds, removes and re-adds the same statement then the cardinality for that statement will be incorrect. We call this effect "staleness". To prevent staleness from affecting the returned cardinalities this class needs to be monitored by calling the staleness(...) method. This will automatically be done every 60 seconds by the ExtensibleSailStore.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.rdf4j.query.algebra.evaluation.impl.EvaluationStatistics
EvaluationStatistics.CardinalityCalculator
-
-
Constructor Summary
Constructors Constructor Description ExtensibleDynamicEvaluationStatistics(ExtensibleSailStore extensibleSailStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ExtensibleStatement statement)
protected EvaluationStatistics.CardinalityCalculator
createCardinalityCalculator()
void
remove(ExtensibleStatement statement)
void
removeByQuery(Resource subj, IRI pred, Value obj, boolean inferred, Resource... contexts)
double
staleness(long expectedSize)
void
waitForQueue()
-
Methods inherited from class org.eclipse.rdf4j.query.algebra.evaluation.impl.EvaluationStatistics
getCardinality
-
-
-
-
Constructor Detail
-
ExtensibleDynamicEvaluationStatistics
public ExtensibleDynamicEvaluationStatistics(ExtensibleSailStore extensibleSailStore)
-
-
Method Detail
-
createCardinalityCalculator
protected EvaluationStatistics.CardinalityCalculator createCardinalityCalculator()
- Specified by:
createCardinalityCalculator
in classExtensibleEvaluationStatistics
-
staleness
public double staleness(long expectedSize)
- Specified by:
staleness
in interfaceDynamicStatistics
- Returns:
- 1 if stale, 0 if not stale, 0.5 if 50% stale. Seen as, given a random statement (that has either been added, or removed), what is the probability that the statistics will return an incorrect result?
-
add
public void add(ExtensibleStatement statement)
- Specified by:
add
in interfaceDynamicStatistics
-
remove
public void remove(ExtensibleStatement statement)
- Specified by:
remove
in interfaceDynamicStatistics
-
removeByQuery
public void removeByQuery(Resource subj, IRI pred, Value obj, boolean inferred, Resource... contexts)
- Specified by:
removeByQuery
in interfaceDynamicStatistics
-
waitForQueue
public void waitForQueue() throws InterruptedException
- Throws:
InterruptedException
-
-