phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ankitsinghal <...@git.apache.org>
Subject [GitHub] phoenix pull request: PHOENIX-1311 HBase namespaces surfaced in ph...
Date Wed, 06 Apr 2016 11:09:02 GMT
Github user ankitsinghal commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/153#discussion_r58687494
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java ---
    @@ -897,4 +941,86 @@ public static boolean hasRowTimestampColumn(PTable table) {
             PName schemaName = dataTable.getSchemaName();
             return getTableKey(tenantId == null ? ByteUtil.EMPTY_BYTE_ARRAY : tenantId.getBytes(),
schemaName == null ? ByteUtil.EMPTY_BYTE_ARRAY : schemaName.getBytes(), dataTable.getTableName().getBytes());
         }
    +
    +    public static byte[] getSchemaKey(String schemaName) {
    +        return SchemaUtil.getTableKey(null, schemaName, MetaDataClient.EMPTY_TABLE);
    +    }
    +
    +    public static PName getPhysicalHBaseTableName(PName pName, boolean isNamespaceMapped,
PTableType type) {
    +        return getPhysicalHBaseTableName(pName.toString(), isNamespaceMapped, type);
    +    }
    +
    +    public static PName getPhysicalHBaseTableName(byte[] tableName, boolean isNamespaceMapped,
PTableType type) {
    +        return getPhysicalHBaseTableName(Bytes.toString(tableName), isNamespaceMapped,
type);
    +    }
    +
    +    public static TableName getPhysicalTableName(String fullTableName, ReadOnlyProps
readOnlyProps) {
    +        return getPhysicalName(Bytes.toBytes(fullTableName), readOnlyProps);
    +    }
    +
    +    public static TableName getPhysicalTableName(byte[] fullTableName, Configuration
conf) {
    +        return getPhysicalTableName(fullTableName, isNamespaceMappingEnabled(
    +                isSystemTable(fullTableName) ? PTableType.SYSTEM : null, new ReadOnlyProps(conf.iterator())));
    +    }
    +
    +    public static TableName getPhysicalName(byte[] fullTableName, ReadOnlyProps readOnlyProps)
{
    +        return getPhysicalTableName(fullTableName,
    +                isNamespaceMappingEnabled(isSystemTable(fullTableName) ? PTableType.SYSTEM
: null, readOnlyProps));
    +    }
    +
    +    public static TableName getPhysicalTableName(byte[] fullTableName, boolean isNamespaceMappingEnabled)
{
    +        if (!isNamespaceMappingEnabled) { return TableName.valueOf(fullTableName); }
    +        String tableName = getTableNameFromFullName(fullTableName);
    +        String schemaName = getSchemaNameFromFullName(fullTableName);
    +        return TableName.valueOf(schemaName, tableName);
    +    }
    +
    +    public static String getSchemaNameFromHBaseFullName(byte[] tableName, ReadOnlyProps
props) {
    +        if (tableName == null) { return null; }
    +        int index = isNamespaceMappingEnabled(null, props) ? indexOf(tableName, QueryConstants.NAMESPACE_SEPARATOR_BYTE)
    +                : indexOf(tableName, QueryConstants.NAME_SEPARATOR_BYTE);
    +        if (index < 0) { return StringUtil.EMPTY_STRING; }
    +        return Bytes.toString(tableName, 0, index);
    +    }
    +
    +    public static PName getPhysicalHBaseTableName(String tableName, boolean isNamespaceMapped,
PTableType type) {
    +        if (!isNamespaceMapped) { return PNameFactory.newName(tableName); }
    +        return PNameFactory
    +                .newName(tableName.replace(QueryConstants.NAME_SEPARATOR, QueryConstants.NAMESPACE_SEPARATOR));
    +    }
    +
    +    public static boolean isSchemaCheckRequired(PTableType tableType, ReadOnlyProps props)
{
    +        if (PTableType.TABLE.equals(tableType) && isNamespaceMappingEnabled(tableType,
props)) { return true; }
    +        return false;
    +    }
    +
    +    public static boolean isNamespaceMappingEnabled(PTableType type, ReadOnlyProps readOnlyProps)
{
    +        return readOnlyProps.getBoolean(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
    +                QueryServicesOptions.DEFAULT_IS_NAMESPACE_MAPPING_ENABLED)
    +                && (type == null || !PTableType.SYSTEM.equals(type)
    --- End diff --
    
    Yes, null is allowed for type here. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message