Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8FD9111FCB for ; Fri, 13 Jun 2014 00:17:07 +0000 (UTC) Received: (qmail 96571 invoked by uid 500); 13 Jun 2014 00:17:02 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 96531 invoked by uid 500); 13 Jun 2014 00:17:02 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 96501 invoked by uid 99); 13 Jun 2014 00:17:02 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2014 00:17:02 +0000 Date: Fri, 13 Jun 2014 00:17:02 +0000 (UTC) From: "Misty Stanley-Jones (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HBASE-11337) Document how to create, modify, delete a table using Java MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-11337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Misty Stanley-Jones updated HBASE-11337: ---------------------------------------- Attachment: (was: HBASE-11337.patch) > Document how to create, modify, delete a table using Java > --------------------------------------------------------- > > Key: HBASE-11337 > URL: https://issues.apache.org/jira/browse/HBASE-11337 > Project: HBase > Issue Type: Bug > Components: Admin, documentation > Reporter: Misty Stanley-Jones > Assignee: Misty Stanley-Jones > Attachments: HBASE-11337.patch > > > Example code from [~jmspaggi] > {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.HBaseAdmin; > 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 createIfNotExist(HBaseAdmin admin, HTableDescriptor table) throws IOException { > if (admin.tableExists(table.getName())) { > admin.disableTable(table.getName()); > admin.deleteTable(table.getName()); > } > admin.createTable(table); > } > public static void main(String[] args) { > /**********************************************************************/ > /***** Create application schema. *************************************/ > /**********************************************************************/ > Configuration config = HBaseConfiguration.create(); > config.set("hbase.zookeeper.quorum", "192.168.56.102"); // Here we are running zookeeper locally > try { > final HBaseAdmin admin = new HBaseAdmin(config); > HTableDescriptor table_assetmeta = new HTableDescriptor(TableName.valueOf(TABLE_ASSETMETA)); > table_assetmeta.addFamily(new HColumnDescriptor(CF_DEFAULT).setCompressionType(Algorithm.GZ)); > System.out.print("Creating table_assetmeta. "); > admin.createTable(table_assetmeta); > System.out.println(" Done."); > admin.close(); > } catch (Exception e) { > e.printStackTrace(); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)