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

James Taylor commented on PHOENIX-2999:
---------------------------------------

[~tdsilva] - maybe you can help [~an...@apache.org] with this?

Here's some feedback:
- Rather than creating an in-memory Set (which could in theory get arbitrarily 
large), how about walking through the ResultSet and calling the upgrade util as 
you're iterating?
- Here's some code copy/pasted from MetaDataEndPointImpl that will walk through 
all child views given a schema and table name (there's no need for that NOT IN 
condition):
{code}
        boolean isMultiTenant = table.isMultiTenant();
        Scan scan = new Scan();
        // If the table is multi-tenant, we need to check across all tenant_ids,
        // so we can't constrain the row key. Otherwise, any views would have
        // the same tenantId.
        if (!isMultiTenant) {
            byte[] startRow = ByteUtil.concat(tenantId, 
QueryConstants.SEPARATOR_BYTE_ARRAY);
            byte[] stopRow = ByteUtil.nextKey(startRow);
            scan.setStartRow(startRow);
            scan.setStopRow(stopRow);
        }
        SingleColumnValueFilter linkFilter = new 
SingleColumnValueFilter(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES, CompareOp.EQUAL, 
linkTypeBytes);
        linkFilter.setFilterIfMissing(true);
        byte[] suffix = ByteUtil.concat(QueryConstants.SEPARATOR_BYTE_ARRAY, 
SchemaUtil
                
.getPhysicalTableName(SchemaUtil.getTableNameAsBytes(schemaName, tableName), 
table.isNamespaceMapped())
                .getName());
        SuffixFilter rowFilter = new SuffixFilter(suffix);
        Filter filter = new FilterList(linkFilter, rowFilter);
        scan.setFilter(filter);
        scan.addColumn(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES);
        scan.addColumn(TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
 {code}

> Upgrading Multi-tenant table to map with namespace using upgradeUtil
> --------------------------------------------------------------------
>
>                 Key: PHOENIX-2999
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2999
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.8.0
>            Reporter: Ankit Singhal
>            Assignee: Ankit Singhal
>            Priority: Critical
>             Fix For: 4.8.0
>
>         Attachments: PHOENIX-2999.patch, PHOENIX-2999_v1.patch, 
> PHOENIX-2999_v2.patch, PHOENIX-2999_v3.patch
>
>
> currently upgradeUtil doesn't handle multi-tenant table with tenant views 
> properly.



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

Reply via email to