public class ASTSimpleGroupByAndCountOptimizer extends Object implements IASTOptimizer
SELECT (COUNT(*) as ?count) ?z WHERE { ?x rdf:type ?z } GROUP BY ?z
and similar patterns using an O(N) algorithm, where N is
the number of distinct solutions.
The optimizer aims at establishing an execution plan that applies a
combination of distinct term scan pattern (to efficiently compute the
distinct values for the group variable) and fast range count pattern to
efficiently calculate the COUNT, without materialization of the variables on
which the COUNT operation is performed.
The basic idea is to
(i) replace the GROUP BY pattern through a SELECT DISTINCT subquery to
calculate the distinct bindings for variable ?z first, and (ii) use a fast
range count operator to efficiently calculate the COUNT.
Note that the sub query in step (i) may (where possible) be optimized by the
ASTDistinctTermScanOptimizer
, i.e. if possible the subquery producing
the ?z bindings will be replaced by a distinct term scan in a later
optimization step.
Constructor and Description |
---|
ASTSimpleGroupByAndCountOptimizer() |
Modifier and Type | Method and Description |
---|---|
QueryNodeWithBindingSet |
optimize(AST2BOpContext context,
QueryNodeWithBindingSet input)
Optimize the AST.
|
public QueryNodeWithBindingSet optimize(AST2BOpContext context, QueryNodeWithBindingSet input)
IASTOptimizer
optimize
in interface IASTOptimizer
context
- The evaluation context.input
- The input to the optimizer, consisting of a queryNode and
input binding set.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.