Github user kaspersorensen commented on a diff in the pull request:
https://github.com/apache/metamodel/pull/182#discussion_r193792898
--- Diff:
hbase/src/main/java/org/apache/metamodel/hbase/HBaseCreateTableBuilder.java ---
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.hbase;
+
+import java.util.Set;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.create.AbstractTableCreationBuilder;
+import org.apache.metamodel.schema.MutableSchema;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.SimpleTableDef;
+
+/**
+ * A builder-class to create tables in a HBase datastore
+ */
+public class HBaseCreateTableBuilder extends
AbstractTableCreationBuilder<HBaseUpdateCallback> {
+
+ private Set<String> _columnFamilies;
+
+ public HBaseCreateTableBuilder(final HBaseUpdateCallback
updateCallback, final Schema schema, final String name) {
+ this(updateCallback, schema, name, null);
+ }
+
+ /**
+ * Create a {@link HBaseCreateTableBuilder}.
+ * Throws an {@link IllegalArgumentException} if the schema isn't a
{@link MutableSchema}.
+ * @param updateCallback
+ * @param schema
+ * @param name
+ * @param columnFamilies
+ */
+ public HBaseCreateTableBuilder(final HBaseUpdateCallback
updateCallback, final Schema schema, final String name,
+ final Set<String> columnFamilies) {
+ super(updateCallback, schema, name);
+ if (!(schema instanceof MutableSchema)) {
+ throw new IllegalArgumentException("Not a mutable schema: " +
schema);
+ }
+ this._columnFamilies = columnFamilies;
+ }
+
+ @Override
+ public Table execute() {
+ if (_columnFamilies == null || _columnFamilies.isEmpty()) {
--- End diff --
I see that we have `DEFAULT_COLUMN_TYPE_FOR_COLUMN_FAMILIES`. So maybe we
could provide this way of creating column/column families:
```
Callback cb = ...
cb.createTable(schema, "My_table")
.withColumn("family1").ofType(DEFAULT_COLUMN_TYPE_FOR_COLUMN_FAMILIES)
.withColumn("family2.foo").ofType(STRING)
.withColumn("family2.bar").ofType(INTEGER)
```
What that would amount to is two column families created: `family1` and
`family2`. The schema for `family1` would not be defined, so it would just be
represented as a single MM Column with type LIST, but the schema for `family2`
will have been defined to contain `foo` and `bar`. Just like how we can
"define" it via a `SimpleTableDef`.
---