summaryrefslogtreecommitdiff
path: root/happybase
diff options
context:
space:
mode:
Diffstat (limited to 'happybase')
-rw-r--r--happybase/__init__.py5
-rw-r--r--happybase/batch.py2
-rw-r--r--happybase/connection.py27
-rw-r--r--happybase/pool.py2
-rw-r--r--happybase/table.py3
-rw-r--r--happybase/util.py2
6 files changed, 21 insertions, 20 deletions
diff --git a/happybase/__init__.py b/happybase/__init__.py
index 11e350d..6f91799 100644
--- a/happybase/__init__.py
+++ b/happybase/__init__.py
@@ -3,11 +3,12 @@ HappyBase, a developer-friendly Python library to interact with Apache
HBase.
"""
+import thriftpy as _thriftpy
+_thriftpy.install_import_hook()
+
from ._version import __version__
from .connection import DEFAULT_HOST, DEFAULT_PORT, Connection
from .table import Table
from .batch import Batch
from .pool import ConnectionPool, NoConnectionsAvailable
-
-# TODO: properly handle errors defined in Thrift specification
diff --git a/happybase/batch.py b/happybase/batch.py
index 5e51410..a8162e9 100644
--- a/happybase/batch.py
+++ b/happybase/batch.py
@@ -6,7 +6,7 @@ from collections import defaultdict
import logging
from numbers import Integral
-from .hbase.ttypes import BatchMutation, Mutation
+from .Hbase_thrift import BatchMutation, Mutation
logger = logging.getLogger(__name__)
diff --git a/happybase/connection.py b/happybase/connection.py
index e52d256..3c1627c 100644
--- a/happybase/connection.py
+++ b/happybase/connection.py
@@ -6,12 +6,11 @@ HappyBase connection module.
import logging
-from thrift.transport.TSocket import TSocket
-from thrift.transport.TTransport import TBufferedTransport, TFramedTransport
-from thrift.protocol import TBinaryProtocol, TCompactProtocol
+from thriftpy.thrift import TClient
+from thriftpy.transport import TBufferedTransport, TFramedTransport, TSocket
+from thriftpy.protocol import TBinaryProtocol, TCompactProtocol
-from .hbase import Hbase
-from .hbase.ttypes import ColumnDescriptor
+from .Hbase_thrift import Hbase, ColumnDescriptor
from .table import Table
from .util import pep8_to_camel_case
@@ -23,8 +22,8 @@ THRIFT_TRANSPORTS = dict(
framed=TFramedTransport,
)
THRIFT_PROTOCOLS = dict(
- binary=TBinaryProtocol.TBinaryProtocolAccelerated,
- compact=TCompactProtocol.TCompactProtocol,
+ binary=TBinaryProtocol,
+ compact=TCompactProtocol,
)
DEFAULT_HOST = 'localhost'
@@ -78,8 +77,8 @@ class Connection(object):
since otherwise you might see non-obvious connection errors or
program hangs when making a connection. ``TCompactProtocol`` is
a more compact binary format that is typically more efficient to
- process as well. ``TBinaryAccelerated`` is the default protocol that
- happybase uses.
+ process as well. ``TBinaryProtocol`` is the default protocol that
+ Happybase uses.
.. versionadded:: 0.9
`protocol` argument
@@ -148,11 +147,11 @@ class Connection(object):
"""Refresh the Thrift socket, transport, and client."""
socket = TSocket(self.host, self.port)
if self.timeout is not None:
- socket.setTimeout(self.timeout)
+ socket.set_timeout(self.timeout)
self.transport = self._transport_class(socket)
- protocol = self._protocol_class(self.transport)
- self.client = Hbase.Client(protocol)
+ protocol = self._protocol_class(self.transport, decode_response=False)
+ self.client = TClient(Hbase, protocol)
def _table_name(self, name):
"""Construct a table name by optionally adding a table name prefix."""
@@ -166,7 +165,7 @@ class Connection(object):
This method opens the underlying Thrift transport (TCP connection).
"""
- if self.transport.isOpen():
+ if self.transport.is_open():
return
logger.debug("Opening Thrift transport to %s:%d", self.host, self.port)
@@ -177,7 +176,7 @@ class Connection(object):
This method closes the underlying Thrift transport (TCP connection).
"""
- if not self.transport.isOpen():
+ if not self.transport.is_open():
return
if logger is not None:
diff --git a/happybase/pool.py b/happybase/pool.py
index 9cc9f69..aa0da99 100644
--- a/happybase/pool.py
+++ b/happybase/pool.py
@@ -8,7 +8,7 @@ import Queue
import socket
import threading
-from thrift.Thrift import TException
+from thriftpy.thrift import TException
from .connection import Connection
diff --git a/happybase/table.py b/happybase/table.py
index 3cb26b7..87be2f6 100644
--- a/happybase/table.py
+++ b/happybase/table.py
@@ -7,7 +7,8 @@ from numbers import Integral
from operator import attrgetter
from struct import Struct
-from .hbase.ttypes import TScan
+from .Hbase_thrift import TScan
+
from .util import thrift_type_to_dict, str_increment, OrderedDict
from .batch import Batch
diff --git a/happybase/util.py b/happybase/util.py
index 355e864..09a4c61 100644
--- a/happybase/util.py
+++ b/happybase/util.py
@@ -45,7 +45,7 @@ def pep8_to_camel_case(name, initial=False):
def thrift_attrs(obj_or_cls):
"""Obtain Thrift data type attribute names for an instance or class."""
- return [v[2] for v in obj_or_cls.thrift_spec[1:]]
+ return [v[1] for v in obj_or_cls.thrift_spec.values()]
def thrift_type_to_dict(obj):