0
我想將數據加載到Hbase,因此我嘗試了一本書HBASE:權威性指南中的簡單示例。 HbaseHelper.java已加載。如何將數據加載到hbase
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
// ^^ PutExample
import util.HBaseHelper;
// vv PutExample
import java.io.IOException;
public class PutExample {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create(); // co PutExample-1-CreateConf Create the required configuration.
// ^^ PutExample
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable1");
helper.createTable("testtable1", "colfam1");
// vv PutExample
HTable table = new HTable(conf, "testtable1"); // co PutExample-2-NewTable Instantiate a new client.
Put put = new Put(Bytes.toBytes("row1")); // co PutExample-3-NewPut Create put with specific row.
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1")); // co PutExample-4-AddCol1 Add a column, whose name is "colfam1:qual1", to the put.
put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"),
Bytes.toBytes("val2")); // co PutExample-4-AddCol2 Add another column, whose name is "colfam1:qual2", to the put.
table.put(put); // co PutExample-5-DoPut Store row with column into the HBase table.
}
}
我做的javac -classpath HBase的-version.jar:hadoop.jar:zookeeper.jar:log4j.jar:公地-logging.jar:公地lang.jar PutData.java(他們是在同一目錄),但不能成功編譯。 據說:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
我嘗試了一些其他類似的方法將數據。錯誤是一樣的。我怎樣才能以任何可能的方式做到這一點?
你安裝了zookeeper嗎?它的運行與否? – 2014-11-06 16:46:49
是的,zookeeper安裝並且版本是3.4.5-cdh5.0.2--1 – chenchenmomo 2014-11-06 17:00:59
檢查這是否與你的問題相同 - http://stackoverflow.com/questions/7470677/some-input-files-use-或重寫的-A-棄用-API – mbaxi 2014-11-07 06:45:22