[
https://issues.apache.org/jira/browse/HBASE-23644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18043467#comment-18043467
]
Xiao Liu commented on HBASE-23644:
----------------------------------
Hi, [~zhangduo], patch for this issue has been submitted. Please review it when
you have time.
Test with python 3.12.8 and thrift 0.14.1, it works well.
First, we use the following commands to start the HBase cluster and Thrift
service.
{code:language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=false}
./bin/start-hbase.sh
./bin/hbase thrift2 start
{code}
Then run the {{DemoClient.py}} script in the {{thrift2}} directory using the
following command:
{code:language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=false}
python thrift2/DemoClient.py [localhost] [9090]
{code}
The output is as follows:
{code:language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=false}
Thrift2 Demo
Usage: DemoClient [host=localhost] [port=9090]
This demo assumes you have a table called "example" with a column family called
"family1"
Putting: TPut(row=b'row1', columnValues=[TColumnValue(family=b'family1',
qualifier=b'qualifier1', value=b'value1', timestamp=None, tags=None,
type=None)], timestamp=None, attributes=None, durability=None,
cellVisibility=None)
Getting: TGet(row=b'row1', columns=None, timestamp=None, timeRange=None,
maxVersions=None, filterString=None, attributes=None, authorizations=None,
consistency=None, targetReplicaId=None, cacheBlocks=None, storeLimit=None,
storeOffset=None, existence_only=None, filterBytes=None)
Result: TResult(row=b'row1', columnValues=[TColumnValue(family=b'family1',
qualifier=b'qualifier1', value=b'value1', timestamp=1765178855388, tags=None,
type=4)], stale=False, partial=False)
row = row1
family = family1
qualifier = qualifier1
value = value1
timestamp = 1765178855388
{code}
> Thrift2 DemoClient.py is not running
> ------------------------------------
>
> Key: HBASE-23644
> URL: https://issues.apache.org/jira/browse/HBASE-23644
> Project: HBase
> Issue Type: Improvement
> Affects Versions: 2.2.2
> Reporter: Madhukumar
> Assignee: Kevin Geiszler
> Priority: Minor
> Labels: pull-request-available
> Fix For: 4.0.0-alpha-1
>
> Attachments: DemoClient.py
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> *hbase-examples/py*
> I tried to connect to hbase thrift2 server with python with given demo file
> DemoClient.py. Issue is the DemoClient.py is not updated for python 3.X.
> Python 2.X support has ended. Even the github vesrion is not updated, happy
> to update it.
> I'm using python 3.8. {color:#ff0000}_Attached file for DemoClient.py for
> python 3.X._ I'm new to Jira and hbase. {color} __
>
> hbase.thrift file that was used to generate gen-py in 2.2.22 release
> examples does seem like this file
> hbase-src-2.2.2/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift.
> _I'm looking for hbase.thrift that was used to get gen-py in py examples. If
> you can point me to that, that will be great._
> {color:#172b4d}If you generate gen-py using thrift compiler 0.13, this is
> error that I'm getting when running DemoClient.py, {color}
> {color:#172b4d}Traceback (most recent call last):
> File "DemoClient.py", line 68, in <module>
> client.put(table, put)
> File
> "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
> line 813, in put
> self.send_put(table, tput)
> File
> "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
> line 821, in send_put
> args.write(self._oprot)
> File
> "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py",
> line 4461, in write
> oprot.writeBinary(self.table)
> File
> "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/protocol/TBinaryProtocol.py",
> line 131, in writeBinary
> self.trans.write(str)
> File
> "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py",
> line 174, in write
> raise e
> File
> "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py",
> line 170, in write
> self.__wbuf.write(buf)
> TypeError: a bytes-like object is required, not 'str'{color}
> {color:#172b4d}Please note that I'm using 0.13 py client package for thrift.
> It does not work with thrift==0.9.3 as well.{color}
> Out of the box gen-py that came with 2.2.2 source examples has the following
> issues working with thrift 0.13 py packages and it is also not code generated
> for python 3.0 but 2.0.
> * ttypes.py > self.__dict.__iteritems() does not work in python 3.0, so it
> need to be items
> * xrange does not work in python 3.0 so all that need to be range
>
> thrift compiler 0.13 was available at this point from apache/thrift. It
> generates the files for python 2.0 it seems because of above two issues
> because hbase.thrift that is src (link given above), not sure what can be
> done about this.
> So, I have 0.13 python thrift package which works with python 3.0.
> DemoClient.py updated to 3.0 but issue is gen-py generation. I don't want to
> edit these generated py files, so if right hbase.thrift file that works with
> thrift 0.13.0 compiler, that will be great. Thanks.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)