【问题标题】:Htable and .add depracated, what should i use instead?this is in scala表和 .add 已弃用,我应该改用什么?这是在 scala 中
【发布时间】:2016-08-01 13:27:03
【问题描述】:

我一直在使用以下函数将我的数据保存到 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。

【问题讨论】:

    标签: scala hbase


    【解决方案1】:

    数据框隐式只支持Hive

    有保存到hbase的库,但是你必须做很多手工工作spark on hbase

    另一种选择是设置Apache Phoenix

    【讨论】:

      猜你喜欢
      • 2015-02-17
      • 1970-01-01
      • 2013-09-01
      • 2019-08-28
      • 2010-09-17
      • 1970-01-01
      • 2014-01-09
      • 2019-03-11
      • 1970-01-01
      相关资源
      最近更新 更多