public class LOCube extends LogicalRelationalOperator
Cube operator syntax
alias = CUBE rel BY { CUBE | ROLLUP }(col_ref) [, { CUBE | ROLLUP }(col_ref) ...];
alias - output alias
CUBE - operator
rel - input relation
BY - operator
CUBE | ROLLUP - cube or rollup operation
col_ref - column references or * or range in the schema referred by rel
The cube computation and rollup computation using UDFs
CubeDimensions
and
RollupDimensions
can be represented like below
events = LOAD '/logs/events' USING EventLoader() AS (lang, event, app_id, event_id, total);
eventcube = CUBE events BY CUBE(lang, event), ROLLUP(app_id, event_id);
result = FOREACH eventcube GENERATE FLATTEN(group) as (lang, event),
COUNT_STAR(cube), SUM(cube.total);
STORE result INTO 'cuberesult';
In the above example, CUBE(lang, event) will generate all combinations of
aggregations {(lang, event), (lang, ), ( , event), ( , )}.
For n dimensions, 2^n combinations of aggregations will be generated.
Similarly, ROLLUP(app_id, event_id) will generate aggregations from the most
detailed to the most general (grandtotal) level in the hierarchical order
like {(app_id, event_id), (app_id, ), ( , )}. For n dimensions,
n+1 combinations of aggregations will be generated.
The output of the above example query will have the following combinations of
aggregations {(lang, event, app_id, event_id), (lang, , app_id, event_id),
( , event, app_id, event_id), ( , , app_id, event_id), (lang, event, app_id, ),
(lang, , app_id, ), ( , event, app_id, ), ( , , app_id, ), (lang, event, , ),
(lang, , , ), ( , event, , ), ( , , , )}
Total number of combinations will be ( 2^n * (n+1) )
Since cube and rollup clause use null to represent "all" values of a dimension,
if the dimension values contain null values it will be converted to "unknown"
before computing cube or rollup.
alias, lineNum, mCustomPartitioner, mPinnedOptions, requestedParallelism, schema
Constructor and Description |
---|
LOCube(LogicalPlan plan) |
LOCube(OperatorPlan plan,
MultiMap<java.lang.Integer,LogicalExpressionPlan> expressionPlans) |
Modifier and Type | Method and Description |
---|---|
void |
accept(PlanVisitor v)
Accept a visitor at this node in the graph.
|
MultiMap<java.lang.Integer,LogicalExpressionPlan> |
getExpressionPlans() |
java.util.List<Operator> |
getInputs(LogicalPlan plan) |
java.util.List<java.lang.String> |
getOperations() |
LogicalSchema |
getSchema()
Get the schema for the output of this relational operator.
|
boolean |
isEqual(Operator other)
This is like a shallow equals comparison.
|
void |
resetUid()
Erase all cached uid, regenerate uid when we regenerating schema.
|
void |
setExpressionPlans(MultiMap<java.lang.Integer,LogicalExpressionPlan> plans) |
void |
setOperations(java.util.List<java.lang.String> operations) |
checkEquality, fixDuplicateUids, getAlias, getCustomPartitioner, getLineNumber, getRequestedParallelism, isPinnedOption, neverUseForRealSetSchema, pinOption, resetSchema, setAlias, setCustomPartitioner, setRequestedParallelism, setSchema, toString
annotate, getAnnotation, getLocation, getName, getPlan, removeAnnotation, setLocation, setPlan
public LOCube(LogicalPlan plan)
public LOCube(OperatorPlan plan, MultiMap<java.lang.Integer,LogicalExpressionPlan> expressionPlans)
public LogicalSchema getSchema() throws FrontendException
LogicalRelationalOperator
getSchema
in class LogicalRelationalOperator
FrontendException
public void accept(PlanVisitor v) throws FrontendException
Operator
accept
in class Operator
v
- Visitor to accept.FrontendException
public boolean isEqual(Operator other) throws FrontendException
Operator
isEqual
in class Operator
FrontendException
public MultiMap<java.lang.Integer,LogicalExpressionPlan> getExpressionPlans()
public void setExpressionPlans(MultiMap<java.lang.Integer,LogicalExpressionPlan> plans)
public void resetUid()
LogicalRelationalOperator
resetUid
in class LogicalRelationalOperator
public java.util.List<Operator> getInputs(LogicalPlan plan)
public java.util.List<java.lang.String> getOperations()
public void setOperations(java.util.List<java.lang.String> operations)
Copyright © 2007-2012 The Apache Software Foundation