Github user karanmehta93 commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/309#discussion_r219310231
  
    --- Diff: phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java 
---
    @@ -1894,10 +1877,36 @@ protected static void 
splitSystemCatalog(Map<String, List<String>> tenantToTable
                     }
                 }
             }
    +
    +    }
    +    
    +    /**
    +     * Splits SYSTEM.CATALOG into multiple regions based on the table or 
view names passed in.
    +     * Metadata for each table or view is moved to a separate region,
    +     * @param tenantToTableAndViewMap map from tenant to tables and views 
owned by the tenant
    +     */
    +    protected static void splitSystemCatalog(Map<String, List<String>> 
tenantToTableAndViewMap) throws Exception  {
    +        List<byte[]> splitPoints = Lists.newArrayListWithExpectedSize(5);
    +        // add the rows keys of the table or view metadata rows
    +        Set<String> schemaNameSet=Sets.newHashSetWithExpectedSize(15);
    +        for (Entry<String, List<String>> entrySet : 
tenantToTableAndViewMap.entrySet()) {
    +            String tenantId = entrySet.getKey();
    +            for (String fullName : entrySet.getValue()) {
    +                String schemaName = 
SchemaUtil.getSchemaNameFromFullName(fullName);
    +                // we don't allow SYSTEM.CATALOG to split within a schema, 
so to ensure each table
    +                // or view is on a separate region they need to have a 
unique tenant and schema name
    +                assertTrue("Schema names of tables/view must be unique ", 
schemaNameSet.add(tenantId+"."+schemaName));
    +                String tableName = 
SchemaUtil.getTableNameFromFullName(fullName);
    +                splitPoints.add(
    +                    SchemaUtil.getTableKey(tenantId, "".equals(schemaName) 
? null : schemaName, tableName));
    +            }
    +        }
    +        Collections.sort(splitPoints, Bytes.BYTES_COMPARATOR);
    +        
splitTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME, 
splitPoints);
    --- End diff --
    
    Does calling `split()` method explicitly check whether the table is allowed 
to split on that key or not by consulting the `MetaDataSplitPolicy ` 


---

Reply via email to