Class ExtensibleDynamicEvaluationStatistics
- All Implemented Interfaces:
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
ConstructorDescriptionExtensibleDynamicEvaluationStatistics
(ExtensibleSailStore extensibleSailStore) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ExtensibleStatement statement) void
remove
(ExtensibleStatement statement) void
removeByQuery
(Resource subj, IRI pred, Value obj, boolean inferred, Resource... contexts) double
staleness
(long expectedSize) void
Methods inherited from class org.eclipse.rdf4j.query.algebra.evaluation.impl.EvaluationStatistics
getCardinality
-
Constructor Details
-
ExtensibleDynamicEvaluationStatistics
-
-
Method Details
-
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
- Specified by:
add
in interfaceDynamicStatistics
-
remove
- 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
- Throws:
InterruptedException
-