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 JoelNothman:
http://wiki.apache.org/hadoop/Hbase/ThriftApi

The comment on the change is:
Provide long-needed update and Python usage

------------------------------------------------------------------------------
  == Thrift API ==
  
+ The design documentation below is now outdated. The latest version of the 
Thrift API is described by 
[http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift?view=co
 Hbase.thrift].
+ 
  This page discusses the effort of creating a Thrift client API. The reasoning 
behind creating a Thrift-based API is that Thrift is both cross-platform and 
more lightweight than REST for many operations.
+ 
+ == Using the API ==
+ 
+ === Generating a Thrift client package ===
+ 
+ Once Thrift is installed, use:
+ 
+ {{{thrift --gen [lang] 
[hbase-root]/src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift}}}
+ 
+ ''lang'' should be one of {{{java}}}, {{{cpp}}}, {{{rb}}}, {{{py}}}, 
{{{perl}}} or another language listed in Hbase.thrift.
+ 
+ This will produce a directory called gen-py, gen-rb, etc. containing the 
appropriate model.
+ 
+ === Starting the Thrift server ===
+ 
+ The Thrift server can be started with:
+ 
+ {{{[hbase-root]/bin/hbase thrift start}}}
+ 
+ === Using with Python ===
+ 
+ See 
[http://yannramin.com/2008/07/19/using-facebook-thrift-with-python-and-hbase/ 
Yann's tutorial] (July 2008).
+ 
+ To acquire a Thrift client instance:
+ {{{
+ from thrift.transport import TSocket, TTransport
+ from thrift.protocol import TBinaryProtocol
+  
+ from hbase import Hbase
+ from hbase.ttypes import *
+ 
+ transport = TSocket.TSocket('localhost', 9090)
+ transport = TTransport.TBufferedTransport(transport)
+ transport.open()
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
+ 
+ client = Hbase.Client(protocol)
+ }}}
+ 
+ 
+ Use {{{help(client)}}} to view the Python API.
+ 
  
  == Data Type Spec ==
  This section contains the definitions of Thrift data types needed for 
communication.
@@ -122, +166 @@

  }}}
  
  
- == Comments ==
+ == Comments on API design ==
  
  Bryan, I think you may want to use the "binary" type instead of "string" to 
avoid any possible encoding issues. "binary" is a raw raw byte[] in Java. -- 
Chad
  

Reply via email to