You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by "David Newcomer (JIRA)" <ji...@apache.org> on 2015/04/30 03:18:06 UTC

[jira] [Created] (HBASE-13599) The Example Provided in Section 69: Examples of the Documentation Does Not Compile

David Newcomer created HBASE-13599:
--------------------------------------

             Summary: The Example Provided in Section 69: Examples of the Documentation Does Not Compile
                 Key: HBASE-13599
                 URL: https://issues.apache.org/jira/browse/HBASE-13599
             Project: HBase
          Issue Type: Bug
          Components: documentation
    Affects Versions: 1.0.0
            Reporter: David Newcomer
            Priority: Minor


I'm trying to build and run the example java code I found in the HBase Documentation, and I'm running into several issues.

1. I don't have the code/library used in the following import:
import static com.example.hbase.Constants.*;

2. All of the methods in createOrOverwrite() that use table.getName() should instead be using table.getTableName()

3. The interface org.apache.hadoop.hbase.client.Admin is abstract, and can't be instantiated with a Configuration. Constructing an org.apache.hadoop.hbase.client.HBaseAdmin would allow the code to compile, but that constructor is deprecated.

4. I have no references to the field "TABLE_NAME" or "CF_DEFAULT". I'm assuming they are Strings in com.example.hbase.Constants. Perhaps those variables should simply be copied into the the Example?

Link to the documentation section:
http://hbase.apache.org/book.html#_examples

<code>

package com.example.hbase.admin;

import java.io.IOException;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
import org.apache.hadoop.conf.Configuration;

import static com.example.hbase.Constants.*;

public class CreateSchema {

  public static void createOrOverwrite(Admin admin, HTableDescriptor table) throws IOException {
    if (admin.tableExists(table.getName())) {
      admin.disableTable(table.getName());
      admin.deleteTable(table.getName());
    }
    admin.createTable(table);
  }

  public static void createSchemaTables (Configuration config) {
    try {
      final Admin admin = new Admin(config);
      HTableDescriptor table = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
      table.addFamily(new HColumnDescriptor(CF_DEFAULT).setCompressionType(Algorithm.SNAPPY));

      System.out.print("Creating table. ");
      createOrOverwrite(admin, table);
      System.out.println(" Done.");

      admin.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }

}

</code>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)