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

James Taylor edited comment on PHOENIX-10 at 2/5/14 7:54 PM:
-------------------------------------------------------------

bq. Which mirror? Sorry not aware of it.
Are you aware of our website?
http://phoenix.incubator.apache.org/source.html

Here's an approach to the client-side of detecting array element references. We 
only care about them in the select expressions list (i.e. 
RowProjector->ColumnProjector->Expression). We'd want to push any 
ArrayIndexFunction expressions, through the Scan coprocessor for server-side 
evaluation. On the client-side, we'd wrap occurrences of ArrayIndexFunction in 
a new expression (similar to ProjectedColumnExpression as described above) 
while we're building the RowProjector. We can bundle this logic inside of the 
ProjectionCompiler:
- Add a List<KeyValueExpression> arrayKeyValueRefs  member variable that'll 
collect the array KV references
- Add a List<Expression> arrayIndexFuncRefs member variable that'll collect the 
ArrayIndexFunction references
- Add an override for the following method:
      public Expression visitLeave(FunctionParseNode node, List<Expression> 
children) throws SQLException
- In this method:
{code}
       Expression func = super.visitLeave(node,children);
       if ArrayIndexFunction.NAME.equals(node.getName()) {
            final List<KeyValueExpression> indexKVs = Lists.newArrayList();
            // Create anon visitor to find reference to array in a generic way
            children.get(0).accept(new KeyValueExpressionVisitor() {
                @Override
                public Void visit(KeyValueColumnExpression expression) {
                    if (expression.getDataType().isArray()) {
                        indexKVs.add(expression);
                    }
                    return null;
                }
            });
            if (!indexKVs.isEmpty()) {
                  // We could try to detect the same ArrayIndexFunction with 
the same index
                  // and then consolidate them, but it's not really worth it.
                  arrayKeyValueRefs.addAll(indexKVs);
                  // Add original func to list that'll get passed to server
                  arrayIndexFuncRefs.add(func);
                  // Wrap the client-side func that'll lookup by index the 
server-side evaluated value
                  func = wrapFuncInArrayElemRefExpression(func, 
arrayIndexFuncRefs.size()-1);
           }
   }
{code}
- Then you just pass through both arrayIndexFuncRefs and arrayKeyValueRefs in 
Scan attributes to the Scan coprocessor




was (Author: jamestaylor):
bq. Which mirror? Sorry not aware of it.
Are you aware of our website?
http://phoenix.incubator.apache.org/source.html

Here's an approach to the client-side of detecting array element references. We 
only care about them in the select expressions list (i.e. 
RowProjector->ColumnProjector->Expression). We'd want to push any 
ArrayIndexFunction expressions, through the Scan coprocessor for server-side 
evaluation. On the client-side, we'd wrap occurrences of ArrayIndexFunction in 
a new expression (similar to ProjectedColumnExpression as described above) 
while we're building the RowProjector. We can bundle this logic inside of the 
ProjectionCompiler:
- Add a List<KeyValueExpression> arrayKeyValueRefs  member variable that'll 
collect the array KV references
- Add a List<Expression> arrayIndexFuncRefs member variable that'll collect the 
ArrayIndexFunction references
- Add an override for the following method:
      public Expression visitLeave(FunctionParseNode node, List<Expression> 
children) throws SQLException
- In this method:
{code}
       Expression func = super.visitLeave(node,children);
       if ArrayIndexFunction.NAME.equals(node.getName()) {
            final List<KeyValueExpression> indexKVs = Lists.newArrayList();
            // Create anon visitor to find reference to array in a generic way
            children.get(0).accept(new KeyValueExpressionVisitor() {
                @Override
                public Void visit(KeyValueColumnExpression expression) {
                    indexKVs.add(expression);
                    return null;
                }
            });
            if (!indexKVs.isEmpty()) {
                  // We could try to detect the same ArrayIndexFunction with 
the same index
                  // and then consolidate them, but it's not really worth it.
                  arrayKeyValueRefs.addAll(indexKVs);
                  // Add original func to list that'll get passed to server
                  arrayIndexFuncRefs.add(func);
                  // Wrap the client-side func that'll lookup by index the 
server-side evaluated value
                  func = wrapFuncInArrayElemRefExpression(func, 
arrayIndexFuncRefs.size()-1);
           }
   }
{code}
- Then you just pass through both arrayIndexFuncRefs and arrayKeyValueRefs in 
Scan attributes to the Scan coprocessor



> Push projection of a single ARRAY element to the server
> -------------------------------------------------------
>
>                 Key: PHOENIX-10
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-10
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: James Taylor
>            Assignee: ramkrishna.s.vasudevan
>         Attachments: Phoenix-10_1.patch
>
>
> If only a single array element is selected, we'll still return the entire 
> array back to the client. Instead, we should push this to the server and only 
> return the single array element. The same goes for the reference to an ARRAY 
> in the WHERE clause. There's a general HBase fix for this (i.e. the ability 
> to define a separate set of key values that will be returned versus key 
> values available to filters) that has a patch here, but is deemed not 
> possible to pull into the 0.94 branch by @lhofhansl.
> My thought is that we can add a Filter at the end our our filter chain that 
> filters out any KeyValues that aren't in the SELECT expressions (i.e. filter 
> out if a column is referenced in the WHERE clause, but not in the SELECT 
> expressions). This same Filter could handle returning only the elements of 
> the array that are referenced in the SELECT expression rather than the entire 
> array.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to