Github user kaspersorensen commented on a diff in the pull request:

    https://github.com/apache/metamodel/pull/182#discussion_r193618625
  
    --- 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 --
    
    Instead of requiring column families to be called out in a way that's not 
part of MetaModel's public API, could we do something smart with e.g. column 
names that represent the column families? For example, we could use a 
dot-separated column name approach, where "family1.foo" and "family1.bar" 
represented two column in the same column family. I think we would need this in 
order to retain compatibility with the public API. I'm not a big fan of 
introducing HBase-specific methods in `UpdateCallback` since we've then kinda 
gone against the idea of using MetaModel in the first place (a uniform API for 
database access).


---

Reply via email to