Re: hbase/jython outdated

2009-08-27 Thread stack
On Wed, Aug 26, 2009 at 3:29 AM, Andrei Savu savu.and...@gmail.com wrote:

 I have fixed the code samples and opened a feature request on JIRA for
 the jython command.

 https://issues.apache.org/jira/browse/HBASE-1796


Thanks.  Patch looks good.  Will commit soon.   Did you update the jython
wiki page?  It seems to be using old API still.


 Is there any python library for REST interface? How stable is the REST
 interface?


Not that I know of (a ruby one, yes IIRC).  Write against stargate if you
are going to do one since o.a.h.h.rest is deprecated in 0.20.0.

St.Ack


Re: hbase/jython outdated

2009-08-27 Thread Andrei Savu
See comments bellow.

On Thu, Aug 27, 2009 at 7:58 PM, stackst...@duboce.net wrote:
 On Wed, Aug 26, 2009 at 3:29 AM, Andrei Savu savu.and...@gmail.com wrote:

 I have fixed the code samples and opened a feature request on JIRA for
 the jython command.

 https://issues.apache.org/jira/browse/HBASE-1796


 Thanks.  Patch looks good.  Will commit soon.   Did you update the jython
 wiki page?  It seems to be using old API still.

I have updated the Jython wiki page to use the latest API. After the
commit I will also
update the instruction for running the sample code.



 Is there any python library for REST interface? How stable is the REST
 interface?


 Not that I know of (a ruby one, yes IIRC).  Write against stargate if you
 are going to do one since o.a.h.h.rest is deprecated in 0.20.0.


I am going give it a try and post the results back here.

What about thrift? It's going to be deprecated?

 St.Ack


-- 
Savu Andrei

Website: http://www.andreisavu.ro/


Re: hbase/jython outdated

2009-08-27 Thread stack
On Wed, Aug 26, 2009 at 3:29 AM, Andrei Savu savu.and...@gmail.com wrote:


 Until recently I have used the python thrift interface but it has some
 serious issues with unicode.


Why does it matter?  HBase is all about byte arrays?  Before you give
content to hbase, do your decode/encode?  See o.a.h.h.util.Bytes for utility
to help here.

The good thing about python over thrift is that you won't be alone.   Other
fellas are coming in that way over the python causeway.

St.Ack


Re: hbase/jython outdated

2009-08-27 Thread stack
On Thu, Aug 27, 2009 at 11:18 AM, Andrei Savu savu.and...@gmail.com wrote:


 What about thrift? It's going to be deprecated?


Thrift is not going anywhere.  It will get a freshener during hbase 0.21
development to align it better with the new hbase client API.  At that time
it will likely be moved out to src/contrib but the thrift interface is here
to stay, at least for the near future.

St.Ack


Re: hbase/jython outdated

2009-08-26 Thread Andrei Savu
I have fixed the code samples and opened a feature request on JIRA for
the jython command.

https://issues.apache.org/jira/browse/HBASE-1796

Until recently I have used the python thrift interface but it has some
serious issues with unicode.
Currently I am searching for alternatives.

Is there any python library for REST interface? How stable is the REST
interface?

On Tue, Aug 25, 2009 at 4:18 PM, Jean-Daniel Cryansjdcry...@apache.org wrote:
 I can edit this page just fine but you have to be logged in to do
 that, anyone can sign in.

 Thx!

 J-D

 On Tue, Aug 25, 2009 at 7:02 AM, Andrei Savusavu.and...@gmail.com wrote:
 Hi,

 The Hbase/Jython ( http://wiki.apache.org/hadoop/Hbase/Jython ) wiki
 page is outdated.
 I want to edit it but the page is marked as immutable.

 I have attached a working sample and a patched version of bin/hbase
 with the jython command added.

 --
 Savu Andrei

 Website: http://www.andreisavu.ro/





-- 
Savu Andrei

Website: http://www.andreisavu.ro/


hbase/jython outdated

2009-08-25 Thread Andrei Savu
Hi,

The Hbase/Jython ( http://wiki.apache.org/hadoop/Hbase/Jython ) wiki
page is outdated.
I want to edit it but the page is marked as immutable.

I have attached a working sample and a patched version of bin/hbase
with the jython command added.

-- 
Savu Andrei

Website: http://www.andreisavu.ro/

import java.lang
from org.apache.hadoop.hbase import HBaseConfiguration, HTableDescriptor, HColumnDescriptor, HConstants
from org.apache.hadoop.hbase.client import HBaseAdmin, HTable
from org.apache.hadoop.hbase.io import BatchUpdate, Cell, RowResult

# 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.
conf = HBaseConfiguration()

# Create a table named 'test' that has two column families,
# one named 'content, and the other 'anchor'.  The colons
# are required for column family names.
tablename = test  

desc = HTableDescriptor(tablename)
desc.addFamily(HColumnDescriptor(content:))
desc.addFamily(HColumnDescriptor(anchor:))
admin = HBaseAdmin(conf)

# Drop and recreate if it exists
if admin.tableExists(tablename):
admin.disableTable(tablename)
admin.deleteTable(tablename)
admin.createTable(desc)

tables = admin.listTables()
table = HTable(conf, tablename)

# Add content to 'column:' on a row named 'row_x'
row = 'row_x'
update = BatchUpdate(row)
update.put('content:', 'some content')
table.commit(update)

# Now fetch the content just added, returns a byte[]
data_row = table.get(row, content:)
data = java.lang.String(data.value, UTF8)

print The fetched row contains the value '%s' % data

# Delete the table.
admin.disableTable(desc.getName())
admin.deleteTable(desc.getName())