[
https://issues.apache.org/jira/browse/PHOENIX-10?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13891882#comment-13891882
]
James Taylor commented on PHOENIX-10:
-------------------------------------
To use KeyValueSchema, you'd do the following:
1. Use KeyValueSchema.KeyValueSchemaBuilder to build one out of the
List<ArrayIndexExpression>. Just loop through each expression and do a
builder.addField(expression). Then at the end, do a builder.build() to
construct it.
2. Then you can use the KeyValueSchema instance to serialize the byte values
into through this call:
byte[] value = keyValueSchema.toBytes(arrayIndexExpressions.toArray(),
ValueBitSet.newInstance(keyValueSchema),
new ImmutableBytesWritable());
3. This byte[] value is the value you'll set on your known, single KeyValue
you're returning.
4. From the client, you can access a particular value by position very similar
to the way ProjectedColumnExpression works, except the this.position will be
the position in your single KeyValue where you expect to find the array
element, and the this.schema will be the KeyValueSchema as created in (2).
Let me know if that's enough to go on.
> 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)