hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Lipcon <t...@cloudera.com>
Subject Re: convert Hbase byte array to long in python?
Date Wed, 07 Dec 2011 21:27:39 GMT
You probably want to use the "struct" module:

In [3]: struct.unpack(">q", "\x00\x00\x00\x00\x00\x00\x00\x05")
Out[3]: (5,)
In [4]: struct.pack(">q", 5)
Out[4]: '\x00\x00\x00\x00\x00\x00\x00\x05'

On Wed, Dec 7, 2011 at 1:20 PM, Allan Spiegel <aspiegel@adobe.com> wrote:
>
> I'm trying to write some Hbase test cases in python using the thrift client.  I'm having
trouble figuring out how to convert the Hbase values (byte arrays) into their original form,
a Long.
>
> While we're at it, I'm sure I'll need to convert in the other direction at some point
(long to byte array)
>
> Thanks!



-- 
Todd Lipcon
Software Engineer, Cloudera

Mime
View raw message