Es-hbase-hbase-listing-table

提供:Dev Guides
移動先:案内検索

HBase-Listado Tabla

++

hbase(main):001:0 > list

HBaseのコマンドと、HBaseのタブラのリストのリストを作成し、継続的に使用することができます。

hbase(main):001:0> list
TABLE
emp

Aquíse puede observar una tabla llamada emp。

JavaのAPIを使用したタブラ

HBaseのAPIを使用して、APIのリストを作成し、APIのAPIを継続的に使用できます。

手順1

メタデータのリストを作成する* ListTables()全体のクラス *HBaseAdmin を使用して、HBaseのタブリストを作成します。 HTableDescriptor オブジェクトの配列を展開します。

//creating a configuration object
Configuration conf = HBaseConfiguration.create();


//Creating HBaseAdmin object
HBaseAdmin admin = new HBaseAdmin(conf);


//Getting all the list of tables using HBaseAdmin object
HTableDescriptor[] tableDescriptor =admin.listTables();

手順2

*HTableDescriptor []* 縦長変数の *HTableDescriptor* クラスを使用します。 タブを使用してオブジェクトを取得する* getNameAsString()*。 HBaseのタブリストを使用するためのユーティリティの概要。

JavaベースのAPIを使用して、HBaseを使用してHBaseを使用して、継続的なプログラムのリストを作成します。

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.client.HBaseAdmin;


public class ListTables
{
   public static void main(String args[])throws MasterNotRunningException, IOException
   {
  //Instantiating a configuration class
   Configuration conf = HBaseConfiguration.create();

  //Instantiating HBaseAdmin class
   HBaseAdmin admin = new HBaseAdmin(conf);

  //Getting all the list of tables using HBaseAdmin object
   HTableDescriptor[] tableDescriptor =admin.listTables();

  //printing all the table names.
   for (int i=0; i<tableDescriptor.length;i++ ){
      System.out.println(tableDescriptor[i].getNameAsString());
   }

   }
 }

連続したプログラムの比較プログラム。

$javac ListTables.java
$java ListTables

Lo siguiente debe ser el producto:

User
emp