{"id":1227,"date":"2011-07-06T10:27:59","date_gmt":"2011-07-06T15:27:59","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=1227"},"modified":"2011-07-06T10:38:01","modified_gmt":"2011-07-06T15:38:01","slug":"simple-hbase-class-to-load-data","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2011\/07\/06\/simple-hbase-class-to-load-data\/","title":{"rendered":"Simple HBase class to load data"},"content":{"rendered":"<p>What is below is a simple java class to load the customers table we created in a <a href=\"http:\/\/appcrawler.com\/wordpress\/2011\/07\/05\/bridging-the-gap-from-sql-to-no-sql\/\" target=\"_blank\">previous post<a><\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport java.util.*;\r\nimport org.apache.hadoop.hbase.client.*;\r\nimport org.apache.hadoop.hbase.util.*;\r\n\r\npublic class putHbase {\r\n  public static void main(String[] args) throws Exception {\r\n        HTable hTable = new HTable(\"customers\");\r\n\r\n    byte[] cust_family = Bytes.toBytes(\"cust_family\");\r\n    byte[] cust_name = Bytes.toBytes(\"cust_name\");\r\n    byte[] cust_address = Bytes.toBytes(\"cust_address\");\r\n    byte[] cust_city = Bytes.toBytes(\"cust_city\");\r\n    byte[] cust_state = Bytes.toBytes(\"cust_state\");\r\n    byte[] cust_zip = Bytes.toBytes(\"cust_zip\");\r\n    byte[] cust_phone = Bytes.toBytes(\"cust_phone\");\r\n\r\n    for (int j = 1; j < 1000; j++) {\r\n      byte[] rowId = Bytes.toBytes(Integer.toString(j));\r\n      Put put = new Put(rowId).add(cust_family, cust_name, Bytes.toBytes(\"Tom Smith\"));\r\n      put.add(cust_family, cust_address, Bytes.toBytes(\"123 Anywhere St.\"));\r\n      put.add(cust_family, cust_city, Bytes.toBytes(\"Columbus\"));\r\n      put.add(cust_family, cust_state, Bytes.toBytes(\"OH\"));\r\n      put.add(cust_family, cust_zip, Bytes.toBytes(\"43215\"));\r\n      put.add(cust_family, cust_phone, Bytes.toBytes(\"614.111.1111\"));\r\n      hTable.put(put);\r\n    }\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is below is a simple java class to load the customers table we created in a previous post import java.util.*; import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.util.*; public class putHbase { public static void main(String[] args) throws Exception { HTable hTable =&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2011\/07\/06\/simple-hbase-class-to-load-data\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,20],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1227"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1227"}],"version-history":[{"count":9,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1227\/revisions"}],"predecessor-version":[{"id":1383,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1227\/revisions\/1383"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1227"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}