Class AttributeEnumeratingSparqlAssemblyModifier
java.lang.Object
cz.cvut.kbss.jopa.query.sparql.loader.AttributeEnumeratingSparqlAssemblyModifier
- All Implemented Interfaces:
SparqlAssemblyModifier
public class AttributeEnumeratingSparqlAssemblyModifier
extends Object
implements SparqlAssemblyModifier
Optimizes entity loading by modifying the query to fetch all named attributes.
This optimizer is applicable for SELECT queries that select instances of an entity class. Instead of loading the instances one by one after the query is evaluated, this optimizer modifies the query to fetch all available entity attributes by injecting optional triple patterns for each of the entity attributes and projecting the values from the query. If the result type has subclasses, all attributes of the subclasses are enumerated in the query so that the instance loading can then determine the result type and load the appropriate instance with all the relevant attribute data.
The injected patterns look like this:
OPTIONAL { ?subject <property> ?value }
If a descriptor with at most one context (for each attribute) is provided, the injected patterns look like this:
OPTIONAL { GRAPH ?g { ?subject <property> ?value } }
Where ?g is determined from the descriptor.
When not to use this modifier:
- When the result type has Properties field
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeEnumeratingSparqlAssemblyModifier(IdentifiableEntityType<?> resultType, Descriptor descriptor) -
Method Summary
Modifier and TypeMethodDescriptionvoidmodify(TokenStreamSparqlQueryHolder queryHolder, org.antlr.v4.runtime.TokenStreamRewriter tokenRewriter, QueryAttributes queryAttributes) Modifies the query.
-
Constructor Details
-
AttributeEnumeratingSparqlAssemblyModifier
public AttributeEnumeratingSparqlAssemblyModifier(IdentifiableEntityType<?> resultType, Descriptor descriptor)
-
-
Method Details
-
modify
public void modify(TokenStreamSparqlQueryHolder queryHolder, org.antlr.v4.runtime.TokenStreamRewriter tokenRewriter, QueryAttributes queryAttributes) Description copied from interface:SparqlAssemblyModifierModifies the query.- Specified by:
modifyin interfaceSparqlAssemblyModifier- Parameters:
queryHolder- Query holdertokenRewriter- Token stream rewriter used to modify the queryqueryAttributes- Query attributes
-