You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by GitBox <gi...@apache.org> on 2019/03/28 03:29:34 UTC

[GitHub] [metamodel] q977734161 commented on a change in pull request #214: Add a method of creating a table with splitKey

q977734161 commented on a change in pull request #214: Add a method of creating a table with splitKey
URL: https://github.com/apache/metamodel/pull/214#discussion_r269846086
 
 

 ##########
 File path: hbase/src/main/java/org/apache/metamodel/hbase/HBaseClient.java
 ##########
 @@ -151,26 +151,53 @@ private boolean rowExists(final Table table, final byte[] rowKey) throws IOExcep
      * @throws MetaModelException when a {@link IOException} is caught
      */
     public void createTable(final String tableName, final Set<String> columnFamilies) {
-        if (tableName == null || columnFamilies == null || columnFamilies.isEmpty()) {
-            throw new IllegalArgumentException("Can't create a table without having the tableName or columnFamilies");
-        }
+        checkTableAndCf(tableName, columnFamilies);
         try (final Admin admin = _connection.getAdmin()) {
-            final TableName hBasetableName = TableName.valueOf(tableName);
-            final TableDescriptorBuilder tableBuilder = TableDescriptorBuilder.newBuilder(hBasetableName);
-            // Add all columnFamilies to the tableDescriptor.
-            for (final String columnFamily : columnFamilies) {
-                // The ID-column isn't needed because, it will automatically be created.
-                if (!columnFamily.equals(HBaseDataContext.FIELD_ID)) {
-                    final ColumnFamilyDescriptor columnDescriptor = ColumnFamilyDescriptorBuilder.of(columnFamily);
-                    tableBuilder.setColumnFamily(columnDescriptor);
-                }
-            }
+            final TableDescriptorBuilder tableBuilder = getTableDescriptorBuilder(tableName, columnFamilies);
             admin.createTable(tableBuilder.build());
         } catch (IOException e) {
             throw new MetaModelException(e);
         }
     }
 
+    /**
+     * Creates a HBase table based on a tableName and it's columnFamilies and splitKeys
+     * @param tableName
+     * @param columnFamilies
+     * @param splitKeys
+     * @throws IllegalArgumentException when any parameter is null
+     * @throws MetaModelException when a {@link IOException} is caught
+     */
+    public void createTable(final String tableName, final Set<String> columnFamilies, byte[][] splitKeys) {
+        checkTableAndCf(tableName, columnFamilies);
 
 Review comment:
   ok,I will spell out "column families" instead of the "cf" abbreviation

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services