[
https://issues.apache.org/jira/browse/PHOENIX-944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14179034#comment-14179034
]
Maryann Xue commented on PHOENIX-944:
-------------------------------------
I wrote the base class for GroupedAggregatingResultIterator as below:
{code}
protected abstract ImmutableBytesWritable getGroupingKey(Tuple tuple);
protected abstract Tuple wrapKeyValueAsResult(KeyValue keyValue);
@Override
public Tuple next() throws SQLException {
Tuple result = resultIterator.next();
if (result == null) {
return null;
}
if (currentKey == null) {
currentKey = getGroupingKey(result);
}
Aggregator[] rowAggregators = aggregators.getAggregators();
aggregators.reset(rowAggregators);
ImmutableBytesWritable nextKey = null;
while (true) {
aggregators.aggregate(rowAggregators, result);
Tuple nextResult = resultIterator.peek();
if (nextResult == null || currentKey.equals(nextKey =
getGroupingKey(nextResult))) {
break;
}
result = resultIterator.next();
}
byte[] value = aggregators.toBytes(rowAggregators);
Tuple tuple = wrapKeyValueAsResult(KeyValueUtil.newKeyValue(currentKey,
SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, AGG_TIMESTAMP, value, 0, value.length));
currentKey = nextKey;
return tuple;
}
{code}
What do you think?
> Support derived tables in FROM clause that needs extra steps of client-side
> aggregation or other processing
> -----------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-944
> URL: https://issues.apache.org/jira/browse/PHOENIX-944
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 3.0.0, 4.0.0, 5.0.0
> Reporter: Maryann Xue
> Assignee: Maryann Xue
> Fix For: 3.0.0, 4.0.0, 5.0.0
>
> Attachments: 944.patch
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> Groupby in both outer and inner queries cannot be flattened. We can apply an
> extra step of client-side aggregation to handle such cases.
> See DerivedTableIT.java for all those examples that are currently not
> supported.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)