public class GroupByRewriter extends Object implements IGroupByRewriteState, IVariableFactory, Serializable
Constructor and Description |
---|
GroupByRewriter(IGroupByRewriteState rewrittenState)
Special construct creates a distinct instance of each
IAggregate
in order to avoid side-effects in the internal state of the
IAggregate functions when evaluated in different contexts (e.g.,
a pipelined aggregation subquery). |
GroupByRewriter(IGroupByState groupByState) |
Modifier and Type | Method and Description |
---|---|
LinkedHashMap<IAggregate<?>,IVariable<?>> |
getAggExpr()
The set of all unique
IAggregate expressions with Bind s
onto anonymous variables. |
IConstraint[] |
getHaving2()
A modified version of the original HAVING expression which has the same
semantics (and
null iff the original was null
or empty). |
IValueExpression<?>[] |
getSelect2()
A modified version of the original SELECT expression which has the same
semantics.
|
static IConstraint |
rewrite(IConstraint e,
IVariableFactory f,
LinkedHashMap<IAggregate<?>,IVariable<?>> aggExpr)
Rewrite an
IConstraint . |
static IValueExpression<?> |
rewrite(IValueExpression<?> e,
IVariableFactory f,
LinkedHashMap<IAggregate<?>,IVariable<?>> aggExpr)
Rewrite an
IValueExpression from a SELECT or HAVING clause. |
String |
toString() |
IVariable<?> |
var()
Return a new anonymous variable (this is overridden by some unit tests in
order to have predictable variable names).
|
public GroupByRewriter(IGroupByRewriteState rewrittenState)
IAggregate
in order to avoid side-effects in the internal state of the
IAggregate
functions when evaluated in different contexts (e.g.,
a pipelined aggregation subquery).rewrittenState
- public GroupByRewriter(IGroupByState groupByState)
public LinkedHashMap<IAggregate<?>,IVariable<?>> getAggExpr()
IAggregate
expressions with Bind
s
onto anonymous variables. Any internal IAggregate
have been
lifted out and will appear before any IAggregate
s which use them.getAggExpr
in interface IGroupByRewriteState
public IValueExpression<?>[] getSelect2()
IAggregate
functions. All IAggregate
functions have been
lifted out into aggExpr
.getSelect2
in interface IGroupByRewriteState
public IConstraint[] getHaving2()
null
iff the original was null
or empty). However, the modified select expressions DO NOT contain any
IAggregate
functions. All IAggregate
functions have been
lifted out into aggExpr
.getHaving2
in interface IGroupByRewriteState
public static IConstraint rewrite(IConstraint e, IVariableFactory f, LinkedHashMap<IAggregate<?>,IVariable<?>> aggExpr)
IConstraint
.
Note: Rewriting a constraint require us to effectively clone the original
constraint. I've hacked this in two ways. First, I assume that the inner
value expression is e.get(0)
. Second, I wrap the rewritten
value expression with #newConstraint(IValueExpression)
. That
factory is responsible for the type of the returned IConstraint
.
public static IValueExpression<?> rewrite(IValueExpression<?> e, IVariableFactory f, LinkedHashMap<IAggregate<?>,IVariable<?>> aggExpr)
IValueExpression
from a SELECT or HAVING clause. If a
rewrite is performed, then the modified expression is returned. Otherwise
the original expression is returned. If an aggregation expression is
lifted out by the rewrite, then it is added to aggExpr.e
- The IValueExpression
.f
- A factory for anonymous variables.aggExpr
- A map associating each unique IAggregate
expression
lifted out of the an IValueExpression
with an
anonymous variable on which the value of the
IAggregate
lifted out the of IValueExpression
will be bound when that IAggregate
is evaluated.IValueExpression
.public IVariable<?> var()
var
in interface IVariableFactory
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.