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

James Taylor commented on PHOENIX-1580:
---------------------------------------

[~ayingshu] - the plans member variable certainly can't be static - but it 
wasn't before. Please re-read my feedback, as you need to:
- Put that in the iterators(List<? extends SQLCloseable>) method instead, like 
this, as it's possible that the same UnionPlan is used to generate iterators 
more than once. You'll need to not make iterators final and add null checks for 
the methods using this member variable. Just return null if iterators is null 
in the getScans() and getRanges() methods.
{code}
+    public final ResultIterator iterator(final List<? extends SQLCloseable> 
dependencies) throws SQLException {
+        this.iterators = new UnionResultIterators(plans);
+        ResultIterator scanner;      
+        boolean isOrdered = (orderBy != null) && 
!orderBy.getOrderByExpressions().isEmpty();
+
+        if (isOrdered) { // TopN
+            scanner = new MergeSortTopNResultIterator(iterators, limit, 
orderBy.getOrderByExpressions());
+        } else {
+            scanner = 
ConcatResultIterator.newIterator(iterators.getIterators());
+            if (limit != null) {
+                scanner = new LimitingResultIterator(scanner, limit);
+            }          
+        }
+        return scanner;
+    }
{code}
- In UnionResultIterators, size all the lists in the constructor, as you have a 
good idea of what the size will be.
- In UnionCompiler, create static constant final PName member variables (not a 
String, but a PName so it's not instantiated over and over again through the 
factory).


> Support UNION ALL
> -----------------
>
>                 Key: PHOENIX-1580
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1580
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Alicia Ying Shu
>            Assignee: Alicia Ying Shu
>         Attachments: PHOENIX-1580-grammar.patch, Phoenix-1580-v1.patch, 
> Phoenix-1580-v2.patch, Phoenix-1580-v3.patch, Phoenix-1580-v4.patch, 
> Phoenix-1580-v5.patch, Phoenix-1580-v6.patch, Phoenix-1580-v7.patch, 
> phoenix-1580-v1-wipe.patch, phoenix-1580.patch, unionall-wipe.patch
>
>
> Select * from T1
> UNION ALL
> Select * from T2



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to