Miki Tebeka avatar Miki Tebeka committed 6bf0b31

changing

Comments (0)

Files changed (7)

+Packing hive thrift client in more Pythonic way
+DEFAULT_HOST = 'localhost'
+DEFAULT_PORT = 10000
+
+from .hive_service import ThriftHive
+from .thrift.transport import TSocket, TTransport
+from .thrift.protocol import TBinaryProtocol
+
+def connect(host=DEFAULT_HOST, port=DEFAULT_PORT):
+    transport = TSocket.TSocket(host, port)
+    transport = TTransport.TBufferedTransport(transport)
+    protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+    client = ThriftHive.Client(protocol)
+    transport.open()
+
+    return client

hive/fb303/FacebookService.py

 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
 
-from thrift.Thrift import *
+from ..thrift.Thrift import *
 from ttypes import *
-from thrift.Thrift import TProcessor
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from ..thrift.Thrift import TProcessor
+from ..thrift.transport import TTransport
+from ..thrift.protocol import TBinaryProtocol
 try:
-  from thrift.protocol import fastbinary
+  from ..thrift.protocol import fastbinary
 except:
   fastbinary = None
 

hive/hive_metastore/ThriftHiveMetastore.py

 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
 
-from thrift.Thrift import *
-import fb303.FacebookService
+from ..thrift.Thrift import *
+from ..fb303 import FacebookService as fb303_FacebookServer
 from ttypes import *
-from thrift.Thrift import TProcessor
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
+from ..thrift.Thrift import TProcessor
+from ..thrift.transport import TTransport
+from ..thrift.protocol import TBinaryProtocol, TProtocol
 try:
-  from thrift.protocol import fastbinary
+  from ..thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
-class Iface(fb303.FacebookService.Iface):
+class Iface(fb303_FacebookService.Iface):
   """
   This interface is live.
   """
     pass
 
 
-class Client(fb303.FacebookService.Client, Iface):
+class Client(fb303_FacebookService.Client, Iface):
   """
   This interface is live.
   """
   def __init__(self, iprot, oprot=None):
-    fb303.FacebookService.Client.__init__(self, iprot, oprot)
+    fb303_FacebookService.Client.__init__(self, iprot, oprot)
 
   def create_database(self, database):
     """
     return
 
 
-class Processor(fb303.FacebookService.Processor, Iface, TProcessor):
+class Processor(fb303_FacebookService.Processor, Iface, TProcessor):
   def __init__(self, handler):
-    fb303.FacebookService.Processor.__init__(self, handler)
+    fb303_FacebookService.Processor.__init__(self, handler)
     self._processMap["create_database"] = Processor.process_create_database
     self._processMap["get_database"] = Processor.process_get_database
     self._processMap["drop_database"] = Processor.process_drop_database

hive/hive_metastore/constants.py

 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
 
-from thrift.Thrift import *
+from ..thrift.Thrift import *
 from ttypes import *
 
 DDL_TIME = "transient_lastDdlTime"

hive/hive_metastore/ttypes.py

 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
 
-from thrift.Thrift import *
-import fb303.ttypes
+from ..thrift.Thrift import *
 
 
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
+from ..thrift.transport import TTransport
+from ..thrift.protocol import TBinaryProtocol, TProtocol
 try:
-  from thrift.protocol import fastbinary
+  from ..thrift.protocol import fastbinary
 except:
   fastbinary = None
 

hive/hive_service/ThriftHive.py

 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
 
-from thrift.Thrift import *
-import hive_metastore.ThriftHiveMetastore
+from ..thrift.Thrift import *
+from ..hive_metastore import ThriftHiveMetastore
 from ttypes import *
-from thrift.Thrift import TProcessor
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
+from ..thrift.Thrift import TProcessor
+from ..thrift.transport import TTransport
+from ..thrift.protocol import TBinaryProtocol, TProtocol
 try:
-  from thrift.protocol import fastbinary
+  from ..thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
-class Iface(hive_metastore.ThriftHiveMetastore.Iface):
+class Iface(ThriftHiveMetastore.Iface):
   def execute(self, query):
     """
     Parameters:
     pass
 
 
-class Client(hive_metastore.ThriftHiveMetastore.Client, Iface):
+class Client(ThriftHiveMetastore.Client, Iface):
   def __init__(self, iprot, oprot=None):
-    hive_metastore.ThriftHiveMetastore.Client.__init__(self, iprot, oprot)
+    ThriftHiveMetastore.Client.__init__(self, iprot, oprot)
 
   def execute(self, query):
     """
     return
 
 
-class Processor(hive_metastore.ThriftHiveMetastore.Processor, Iface, TProcessor):
+class Processor(ThriftHiveMetastore.Processor, Iface, TProcessor):
   def __init__(self, handler):
-    hive_metastore.ThriftHiveMetastore.Processor.__init__(self, handler)
+    ThriftHiveMetastore.Processor.__init__(self, handler)
     self._processMap["execute"] = Processor.process_execute
     self._processMap["fetchOne"] = Processor.process_fetchOne
     self._processMap["fetchN"] = Processor.process_fetchN
   """
 
   thrift_spec = (
-    (0, TType.STRUCT, 'success', (hive_metastore.ttypes.Schema, hive_metastore.ttypes.Schema.thrift_spec), None, ), # 0
+    (0, TType.STRUCT, 'success', (ttypes.Schema, hive_metastore.ttypes.Schema.thrift_spec), None, ), # 0
     (1, TType.STRUCT, 'ex', (HiveServerException, HiveServerException.thrift_spec), None, ), # 1
   )
 
         break
       if fid == 0:
         if ftype == TType.STRUCT:
-          self.success = hive_metastore.ttypes.Schema()
+          self.success = ttypes.Schema()
           self.success.read(iprot)
         else:
           iprot.skip(ftype)
   """
 
   thrift_spec = (
-    (0, TType.STRUCT, 'success', (hive_metastore.ttypes.Schema, hive_metastore.ttypes.Schema.thrift_spec), None, ), # 0
+    (0, TType.STRUCT, 'success', (ttypes.Schema, hive_metastore.ttypes.Schema.thrift_spec), None, ), # 0
     (1, TType.STRUCT, 'ex', (HiveServerException, HiveServerException.thrift_spec), None, ), # 1
   )
 
         break
       if fid == 0:
         if ftype == TType.STRUCT:
-          self.success = hive_metastore.ttypes.Schema()
+          self.success = ttypes.Schema()
           self.success.read(iprot)
         else:
           iprot.skip(ftype)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.