[
https://issues.apache.org/jira/browse/PHOENIX-1620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
James Taylor updated PHOENIX-1620:
----------------------------------
Attachment: 1620_v2.patch
Working patch with tests. One interesting case to think about is how this
would/should work with a multi-tenant local index. These have the following
format:
<data region start key><tenant_id><index_id><indexed_values>
With some hacking, we could create an expression that would skip the prepended
region start key to get to the tenant ID part. It'd be a bit painful, as
there's a case where we prepend zero bytes and we wouldn't know how many. We
could skip all leading zero bytes in that case safely, as the tenant ID cannot
contain null bytes. The other region start keys would be valid data row keys,
so we could skip those by getting the data row key schema and navigating past
them.
However, the use case for this function is to support backups, I believe. I
don't think we'd want to transfer the prepended region start key to a DR
cluster, as that cluster would have it's own regions with its own region
boundaries. I think this would require special case code. My implementation
just throws a SQLFeatureNotSupportedException for this situation currently.
Thoughts [~rajeshbabu], [~lhofhansl]?
> Add API for getting tenant ID from an HBase row of a Phoenix table
> ------------------------------------------------------------------
>
> Key: PHOENIX-1620
> URL: https://issues.apache.org/jira/browse/PHOENIX-1620
> Project: Phoenix
> Issue Type: Bug
> Reporter: James Taylor
> Attachments: 1620.patch, 1620_v2.patch
>
>
> Provide a means for HBase-level tools to get the tenant ID from an HBase row
> of any Phoenix table by adding the following method to PhoenixRuntime:
> public static Expression getTenantIdExpression(PhoenixConnection conn,
> String fullTableName);
> Then you'd call this once to get back an Expression which could be used again
> and again to get the tenantId from a List<Cell>, like this:
> Tuple tuple = new MultiKeyValueTuple();
> ImmutableBytesWritable ptr = new ImmutableBytesWritable();
> Expression expression = PhoenixRuntime.getTenantIdExpression(conn,
> fullTableName);
> while (more rows) {
> List<Cell> cells = get cells from row
> tuple.setKeyValues(cells);
> expression.evaluate(tuple, ptr);
> // At this point ptr would point to the tenant ID with its offset and
> length
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)