Thrift: Python TBufferedTransport improvements.
Summary:
The Python version of TBufferedTransport now uses input buffering.
It is also compatible with the fasbinary module.
Reviewed By: mcslee
Test Plan:
test/FastbinaryTest.py
dreiss@dreiss-vmware:~/gp/thrift/test/py$ strace -f ./TestClient.py 2>&1 | grep recv | wc -l
99
# Install new version in other terminal
dreiss@dreiss-vmware:~/gp/thrift/test/py$ strace -f ./TestClient.py 2>&1 | grep recv | wc -l
14
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665250 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/FastbinaryTest.py b/test/FastbinaryTest.py
index 0918002..f6a8699 100755
--- a/test/FastbinaryTest.py
+++ b/test/FastbinaryTest.py
@@ -79,6 +79,10 @@
rs.bigint = 124523452435L
rs.triple = 3.14
+# make sure this splits two buffers in a buffered protocol
+rshuge = RandomStuff()
+rshuge.myintlist=range(10000)
+
my_zero = Srv.Janky_result({"arg":5})
my_nega = Srv.Janky_args({"success":6})
@@ -98,9 +102,22 @@
def checkRead(o):
prot = TBinaryProtocol.TBinaryProtocol(TTransport.TMemoryBuffer())
o.write(prot)
+
+ slow_version_binary = prot.trans.getvalue()
+
prot = TBinaryProtocol.TBinaryProtocolAccelerated(
- TTransport.TMemoryBuffer(
- prot.trans.getvalue()))
+ TTransport.TMemoryBuffer(slow_version_binary))
+ c = o.__class__()
+ c.read(prot)
+ if c != o:
+ print "copy: "
+ pprint(eval(repr(c)))
+ print "orig: "
+ pprint(eval(repr(o)))
+
+ prot = TBinaryProtocol.TBinaryProtocolAccelerated(
+ TTransport.TBufferedTransport(
+ TTransport.TMemoryBuffer(slow_version_binary)))
c = o.__class__()
c.read(prot)
if c != o:
@@ -117,6 +134,8 @@
checkRead(no_set)
checkWrite(rs)
checkRead(rs)
+ checkWrite(rshuge)
+ checkRead(rshuge)
checkWrite(my_zero)
checkRead(my_zero)
checkRead(Backwards({"first_tag2":4, "second_tag1":2}))