kaspersorensen 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_r268305667
 
 

 ##########
 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:
   I think you should 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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to