HBASE-23854 replaced deprecated code in Example Scala Code section

Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
Michael 2020-02-16 11:59:30 +01:00 committed by Sean Busbey
parent 0b2eb3594b
commit 400b7ce954
1 changed files with 11 additions and 13 deletions

View File

@ -934,16 +934,15 @@ libraryDependencies ++= Seq(
=== Example Scala Code === Example Scala Code
This example lists HBase tables, creates a new table, and adds a row to it. This example lists HBase tables, creates a new table, adds a row to it, and gets the value of the row.
[source, scala] [source, scala]
---- ----
import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.{HBaseConfiguration, TableName}
import org.apache.hadoop.hbase.client.{Connection,ConnectionFactory,HBaseAdmin,HTable,Put,Get} import org.apache.hadoop.hbase.client.{Admin, Connection, ConnectionFactory, Get, Put}
import org.apache.hadoop.hbase.util.Bytes import org.apache.hadoop.hbase.util.Bytes
val conf = HBaseConfiguration.create()
val conf = new HBaseConfiguration()
val connection = ConnectionFactory.createConnection(conf); val connection = ConnectionFactory.createConnection(conf);
val admin = connection.getAdmin(); val admin = connection.getAdmin();
@ -952,12 +951,11 @@ val listtables=admin.listTables()
listtables.foreach(println) listtables.foreach(println)
// let's insert some data in 'mytable' and get the row // let's insert some data in 'mytable' and get the row
val table = connection.getTable(TableName.valueOf("mytable"))
val table = new HTable(conf, "mytable")
val theput = new Put(Bytes.toBytes("rowkey1")) val theput = new Put(Bytes.toBytes("rowkey1"))
theput.add(Bytes.toBytes("ids"),Bytes.toBytes("id1"),Bytes.toBytes("one")) theput.addColumn(Bytes.toBytes("ids"),Bytes.toBytes("id1"),Bytes.toBytes("one"))
table.put(theput) table.put(theput)
val theget = new Get(Bytes.toBytes("rowkey1")) val theget = new Get(Bytes.toBytes("rowkey1"))