You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2020/02/21 21:06:31 UTC
[hbase] branch master updated (4381b18 -> 400b7ce)
This is an automated email from the ASF dual-hosted git repository.
busbey pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git.
from 4381b18 replaced deprecated code in Example Scala Code section
new 0b2eb35 Revert "replaced deprecated code in Example Scala Code section"
new 400b7ce HBASE-23854 replaced deprecated code in Example Scala Code section
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[hbase] 01/02: Revert "replaced deprecated code in Example Scala
Code section"
Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
busbey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 0b2eb3594b0a464fca82057d282fff819327503a
Author: Sean Busbey <bu...@apache.org>
AuthorDate: Fri Feb 21 15:05:16 2020 -0600
Revert "replaced deprecated code in Example Scala Code section"
This reverts commit 4381b18b873c5813af561bf75e567bf4d2215da5.
---
src/main/asciidoc/_chapters/external_apis.adoc | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/main/asciidoc/_chapters/external_apis.adoc b/src/main/asciidoc/_chapters/external_apis.adoc
index 129094e..b7aebb4 100644
--- a/src/main/asciidoc/_chapters/external_apis.adoc
+++ b/src/main/asciidoc/_chapters/external_apis.adoc
@@ -934,33 +934,35 @@ libraryDependencies ++= Seq(
=== Example Scala Code
-This example lists HBase tables, creates a new table, adds a row to it, and gets the value of the row.
+This example lists HBase tables, creates a new table, and adds a row to it.
[source, scala]
----
-import org.apache.hadoop.hbase.{HBaseConfiguration, TableName}
-import org.apache.hadoop.hbase.client.{Admin, Connection, ConnectionFactory, Get, Put}
+import org.apache.hadoop.hbase.HBaseConfiguration
+import org.apache.hadoop.hbase.client.{Connection,ConnectionFactory,HBaseAdmin,HTable,Put,Get}
import org.apache.hadoop.hbase.util.Bytes
-val conf = HBaseConfiguration.create()
+
+val conf = new HBaseConfiguration()
val connection = ConnectionFactory.createConnection(conf);
val admin = connection.getAdmin();
// list the tables
-val listtables = admin.listTables()
+val listtables=admin.listTables()
listtables.foreach(println)
// let's insert some data in 'mytable' and get the row
-val table = connection.getTable(TableName.valueOf("mytable"))
-val theput = new Put(Bytes.toBytes("rowkey1"))
+val table = new HTable(conf, "mytable")
+
+val theput= new Put(Bytes.toBytes("rowkey1"))
-theput.addColumn(Bytes.toBytes("ids"),Bytes.toBytes("id1"),Bytes.toBytes("one"))
+theput.add(Bytes.toBytes("ids"),Bytes.toBytes("id1"),Bytes.toBytes("one"))
table.put(theput)
-val theget = new Get(Bytes.toBytes("rowkey1"))
-val result = table.get(theget)
-val value = result.value()
+val theget= new Get(Bytes.toBytes("rowkey1"))
+val result=table.get(theget)
+val value=result.value()
println(Bytes.toString(value))
----
[hbase] 02/02: HBASE-23854 replaced deprecated code in Example
Scala Code section
Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
busbey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 400b7ce95496e30ccdc985ad4c32ac376317990f
Author: Michael <mi...@gmx.de>
AuthorDate: Sun Feb 16 11:59:30 2020 +0100
HBASE-23854 replaced deprecated code in Example Scala Code section
Signed-off-by: Sean Busbey <bu...@apache.org>
---
src/main/asciidoc/_chapters/external_apis.adoc | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/main/asciidoc/_chapters/external_apis.adoc b/src/main/asciidoc/_chapters/external_apis.adoc
index b7aebb4..129094e 100644
--- a/src/main/asciidoc/_chapters/external_apis.adoc
+++ b/src/main/asciidoc/_chapters/external_apis.adoc
@@ -934,35 +934,33 @@ libraryDependencies ++= Seq(
=== 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]
----
-import org.apache.hadoop.hbase.HBaseConfiguration
-import org.apache.hadoop.hbase.client.{Connection,ConnectionFactory,HBaseAdmin,HTable,Put,Get}
+import org.apache.hadoop.hbase.{HBaseConfiguration, TableName}
+import org.apache.hadoop.hbase.client.{Admin, Connection, ConnectionFactory, Get, Put}
import org.apache.hadoop.hbase.util.Bytes
-
-val conf = new HBaseConfiguration()
+val conf = HBaseConfiguration.create()
val connection = ConnectionFactory.createConnection(conf);
val admin = connection.getAdmin();
// list the tables
-val listtables=admin.listTables()
+val listtables = admin.listTables()
listtables.foreach(println)
// 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)
-val theget= new Get(Bytes.toBytes("rowkey1"))
-val result=table.get(theget)
-val value=result.value()
+val theget = new Get(Bytes.toBytes("rowkey1"))
+val result = table.get(theget)
+val value = result.value()
println(Bytes.toString(value))
----