Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change 
notification.

The following page has been changed by BillyPearson:
http://wiki.apache.org/hadoop/Hbase/FAQ

------------------------------------------------------------------------------
  
  The two main client-side entry points are 
[http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Nightly/javadoc/org/apache/hadoop/hbase/HBaseAdmin.html
 HBaseAdmin] and 
[http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Nightly/javadoc/org/apache/hadoop/hbase/HTable.html
 HTable].  Use H!BaseAdmin to create, drop, list, enable and disable tables.  
Use it also to add and drop table column families.  For adding, updating and 
deleting data, use HTable.  Here is some pseudo code absent error checking, 
imports, etc., that creates a table, adds data, does a fetch of just-added data 
and then deletes the table.
  
- {{{// First get a conf object.  This will read in the configuration
+ {{{// First get a conf object.  This will read in the configuration 
  // that is out in your hbase-*.xml files such as location of the
  // hbase master node.
  HBaseConfiguration conf = new HBaseConfiguration();
@@ -24, +24 @@

  // one named 'content, and the other 'anchor'.  The colons
  // are required for column family names.
  HTableDescriptor desc = new HTableDescriptor("test");
- desc.addFamily(new HColumnDescriptor(new Text("content:")));
+ desc.addFamily(new HColumnDescriptor("content:"));
- desc.addFamily(new HColumnDescriptor(new Text("anchor:")));
+ desc.addFamily(new HColumnDescriptor("anchor:"));
  HBaseAdmin admin = new HBaseAdmin(conf);
  admin.createTable(desc);
  HTableDescriptor[] tables = admin.listTables();
  // New table should be in list of returned tables.
  // Or you could call admin.exists();
  
+ HTable table = new HTable(conf, new Text("test"));
  // Add content to 'column:' on a row named 'row_x'
  Text row = new Text("row_x");
  BatchUpdate update = new BatchUpdate(row);
  update.put("content:",
    "some content".getBytes(HConstants.UTF8_ENCODING));
  table.commit(update);
- 
  // Now fetch the content just added
- byte data[] = table.get(row, "content:");
+ byte data[] = table.get(row, new Text("content:"));
- 
  // Delete the table.
  admin.deleteTable(desc.getName());}}}
  

Reply via email to