从HBase中的HDFS导入表

时间:2015-11-09 15:38:17

标签: hbase hdfs apache-pig

我在猪中创建了一个表并将其存储在hdfs:

Data[]

在hdfs上运行ls命令,我得到了表:

int lucky;
int Data[]= new int[20];

for(int i=0;i<Data.length;i++){
    Data[i]=(int)(Math.random()*100);
}
for(int i=0;i<Data.length;++i){
    System.out.println(Data[i]+"\t");

}

String input1=JOptionPane.showInputDialog("Enter your lucky number");
lucky=Integer.parseInt(input1);
System.out.println(lucky);

但是在HBase shell中运行list命令时,表格不会出现。

我正在使用:

STORE mapping INTO  'hdfs://localhost:9000/hbase/data/default/mapping' USING PigStorage ('\t');

所有在一台虚拟机上运行

如何在HBase中导入表格?

1 个答案:

答案 0 :(得分:2)

首先使用HBaseHCatStorageHandler或直接从HBase shell在HBase中创建表。

CREATE TABLE meters (col1 STRING, col2 STRING) STORED BY 'org.apache.hcatalog.hbase.HBaseHCatStorageHandler' TBLPROPERTIES ( 'hbase.table.name' = 'meters', 'hbase.columns.mapping' = 'd:col2', 'hcat.hbase.output.bulkMode' = 'true' ) ;

col1-将成为HBase表的Rowkey col2-将成为列族“d”

下的列限定符

现在使用STORE命令将数据加载到此表中。