[jira] [Commented] (PHOENIX-418) Support approximate COUNT DISTINCT

2017-08-05 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/PHOENIX-418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16115574#comment-16115574
 ] 

Hadoop QA commented on PHOENIX-418:
---

{color:red}-1 overall{color}.  Here are the results of testing the latest 
attachment 
  http://issues.apache.org/jira/secure/attachment/12880542/PHOENIX-418-v3.patch
  against master branch at commit bf3c13b6d169e90e06c54a338a5931163a32d743.
  ATTACHMENT ID: 12880542

{color:green}+1 @author{color}.  The patch does not contain any @author 
tags.

{color:red}-1 tests included{color}.  The patch doesn't appear to include 
any new or modified tests.
Please justify why no new tests are needed for this 
patch.
Also please list what manual steps were performed to 
verify this patch.

{color:green}+1 javac{color}.  The applied patch does not increase the 
total number of javac compiler warnings.

{color:red}-1 javadoc{color}.  The javadoc tool appears to have generated 
54 warning messages.

{color:green}+1 release audit{color}.  The applied patch does not increase 
the total number of release audit warnings.

{color:red}-1 lineLengths{color}.  The patch introduces the following lines 
longer than 100:
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String query = "SELECT 
APPROX_COUNT_DISTINCT(ORGANIZATION_ID||A_STRING||B_STRING) FROM " + tableName;
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String query = "SELECT 
APPROX_COUNT_DISTINCT(a.ORGANIZATION_ID||a.A_STRING||b.ENTITY_ID) FROM " 
+   + tableName + " a, "+ tableName + " b where 
a.ORGANIZATION_ID=b.ORGANIZATION_ID and a.ENTITY_ID = b.ENTITY_ID";
+String tableName = initATableValues(null, tenantId, 
getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
+String query = "explain SELECT 
APPROX_COUNT_DISTINCT(ORGANIZATION_ID||ENTITY_ID) FROM " + tableName;

 {color:red}-1 core tests{color}.  The patch failed these unit tests:
 
./phoenix-core/target/failsafe-reports/TEST-org.apache.phoenix.end2end.CreateTableIT
./phoenix-core/target/failsafe-reports/TEST-org.apache.phoenix.end2end.ScanQueryIT
./phoenix-core/target/failsafe-reports/TEST-org.apache.phoenix.end2end.ClientTimeArithmeticQueryIT

Test results: 
https://builds.apache.org/job/PreCommit-PHOENIX-Build/1245//testReport/
Javadoc warnings: 
https://builds.apache.org/job/PreCommit-PHOENIX-Build/1245//artifact/patchprocess/patchJavadocWarnings.txt
Console output: 
https://builds.apache.org/job/PreCommit-PHOENIX-Build/1245//console

This message is automatically generated.

> Support approximate COUNT DISTINCT
> --
>
> Key: PHOENIX-418
> URL: https://issues.apache.org/jira/browse/PHOENIX-418
> Project: Phoenix
>  Issue Type: Task
>Reporter: James Taylor
>Assignee: Ethan Wang
>  Labels: gsoc2016
> Attachments: PHOENIX-418-v1.patch, PHOENIX-418-v2.patch, 
> PHOENIX-418-v3.patch
>
>
> Support an "approximation" of count distinct to prevent having to hold on to 
> all distinct values (since this will not scale well when the number of 
> distinct values is huge). The Apache Drill folks have had some interesting 
> discussions on this 
> [here](http://mail-archives.apache.org/mod_mbox/incubator-drill-dev/201306.mbox/%3CJIRA.12650169.1369931282407.88049.1370645900553%40arcas%3E).
>  They recommend using  [Welford's 
> method](http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance_Online_algorithm).
>  I'm open to having a config option that uses exact versus approximate. I 
> don't have experience implementing an approximate implementation, so I'm not 
> sure how much state is required to keep on the server and return to the 
> client (other than realizing it'd be much less that returning all distinct 
> values and their counts).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (PHOENIX-418) Support approximate COUNT DISTINCT

2017-08-05 Thread James Taylor (JIRA)

[ 
https://issues.apache.org/jira/browse/PHOENIX-418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16115513#comment-16115513
 ] 

James Taylor commented on PHOENIX-418:
--

Thanks for the patch, [~aertoria]. The transitive dependencies of licenses look 
fine. Here's some feedback:
- You should be able to derive DistinctCountHyperLogLogAggregateFunction from 
DistinctCountAggregateFunction and simply override the getName, 
newClientAggregator and newServerAggregator methods. The behavior for things 
like COUNT(DISTINCT 123)) should be the same as 
APPROXIMATE_COUNT_DISTINCT(123), returning either 0 or 1. The getDataType and 
evaluate method will be the same as DistinctCountAggregateFunction: the return 
type should always be of type PLong and the evaluate method will have the same 
special cases when a constant is used as the argument.
{code}
+
+@BuiltInFunction(name=DistinctCountHyperLogLogAggregateFunction.NAME, 
nodeClass=DistinctCountHyperLogLogAggregateParseNode.class, args= {@Argument()} 
)
+public class DistinctCountHyperLogLogAggregateFunction extends 
DelegateConstantToCountAggregateFunction {
+public static final String NAME = "APPROX_COUNT_DISTINCT";
+
+public DistinctCountHyperLogLogAggregateFunction() {
+}
+
+public DistinctCountHyperLogLogAggregateFunction(List 
childExpressions){
+super(childExpressions, null);
+}
+
+public DistinctCountHyperLogLogAggregateFunction(List 
childExpressions, CountAggregateFunction delegate){
+super(childExpressions, delegate);
+}
+
+
+private Aggregator newAggregatorServer(final PDataType type, SortOrder 
sortOrder, ImmutableBytesWritable ptr) {
+   return new HyperLogLogServerAggregator(sortOrder, ptr) {
+@Override
+protected PDataType getInputDataType() {
+  return type;
+}
+  };
+}
{code}
- Minor nit, but if you include an @since tag, make the release the *next* 
release (i.e. the release this function will appear in), not the current 
release:
{code}
+ * @since 4.11
{code}

> Support approximate COUNT DISTINCT
> --
>
> Key: PHOENIX-418
> URL: https://issues.apache.org/jira/browse/PHOENIX-418
> Project: Phoenix
>  Issue Type: Task
>Reporter: James Taylor
>Assignee: Ethan Wang
>  Labels: gsoc2016
> Attachments: PHOENIX-418-v1.patch, PHOENIX-418-v2.patch, 
> PHOENIX-418-v3.patch
>
>
> Support an "approximation" of count distinct to prevent having to hold on to 
> all distinct values (since this will not scale well when the number of 
> distinct values is huge). The Apache Drill folks have had some interesting 
> discussions on this 
> [here](http://mail-archives.apache.org/mod_mbox/incubator-drill-dev/201306.mbox/%3CJIRA.12650169.1369931282407.88049.1370645900553%40arcas%3E).
>  They recommend using  [Welford's 
> method](http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance_Online_algorithm).
>  I'm open to having a config option that uses exact versus approximate. I 
> don't have experience implementing an approximate implementation, so I'm not 
> sure how much state is required to keep on the server and return to the 
> client (other than realizing it'd be much less that returning all distinct 
> values and their counts).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)