我一直在使用以下功能将我的数据保存到Hbase中,有人可以帮助我如何使用更新的api或某些示例吗?以下是我的代码:
def getConnection():(Connection, Configuration) ={
val config = HBaseConfiguration.create()
config.set("hbase.zookeeper.quorum", "node-01.algo,node-02.algo")
config.set("hbase.master", "node-01.algo:60000")
config.set("zk.connectiontimeout.ms", "10000")
config.set("hbase.zookeeper.property.clientport", "2181")
config.set("zookeeper.znode.parent", "/hbase-unsecure")
val connection = ConnectionFactory.createConnection(config)
(connection, config)
}
def addRecord(tableName: String, rowKey: String, family: String, qualifier: String, value: String) ={
val conTuple = getConnection()
val connection = conTuple._1
val table = new HTable(conTuple._2, tableName)
val theput= new Put(Bytes.toBytes(rowKey))
theput.add(Bytes.toBytes(family), Bytes.toBytes(qualifier), Bytes.toBytes(value))
table.put(theput)
table.close()
connection.close()
}
Htable已被删除,并要求我改用Table。