[ https://issues.apache.org/jira/browse/PHOENIX-1311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15228109#comment-15228109 ]
ASF GitHub Bot commented on PHOENIX-1311: ----------------------------------------- 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. > HBase namespaces surfaced in phoenix > ------------------------------------ > > Key: PHOENIX-1311 > URL: https://issues.apache.org/jira/browse/PHOENIX-1311 > Project: Phoenix > Issue Type: New Feature > Reporter: nicolas maillard > Assignee: Ankit Singhal > Priority: Minor > Fix For: 4.8.0 > > Attachments: PHOENIX-1311.docx, PHOENIX-1311_v1.patch, > PHOENIX-1311_v2.patch, PHOENIX-1311_wip.patch, PHOENIX-1311_wip_2.patch > > > Hbase (HBASE-8015) has the concept of namespaces in the form of > myNamespace:MyTable it would be great if Phoenix leveraged this feature to > give a database like feature on top of the table. > Maybe to stay close to Hbase it could also be a create DB:Table... > or DB.Table which is a more standard annotation? -- This message was sent by Atlassian JIRA (v6.3.4#6332)