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

James Taylor commented on PHOENIX-10:
-------------------------------------

The array column will have been projected into the scan, so you'll have the 
KeyValue that with the entire array as its byte value in the List<KeyValue> 
result. You'd need to use the logic for accessing a particular array element. 
You could access a particular element by doing the following:

/**
 * Serialized over from the client a List<ArrayIndexExpression> of all the 
array index expressions
 * The ArrayIndexExpression will contain a KeyValueColumnExpression as a child.
 * Use the KeyValueExpressionVisitor to form a parallel array of 
List<KeyValueColumnExpression>
 * You can use this List to detect which KeyValues in the result should be 
extracted and placed
 * in your single, specially named KeyValue. Once detected, evaluate the 
corresponding
 * ArrayIndexExpression like this:
 */
Tuple tuple = new MultiKeyValueTuple(keyValues);
ArrayIndexExpression elemExpr = elemExprList.get(i);
elemExpr.evaluate(tuple, ptr);
// At this point, ptr will be pointing at the array element, so you'd want to 
add
// it to your byte array your building that will hold all the referenced array 
elements

I think this kind of post-processing is best done in a coprocessor, as you can 
allocate your byte array that'll hold all the referenced array elements and 
just add to it all in the scope of a single function.



> 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
>
> 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