hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zs...@apache.org
Subject svn commit: r697291 [9/31] - in /hadoop/core/trunk: ./ src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/ src/contrib/hive/metastore/if/ src/contrib/hive/metastore/src/gen-javabean/org/apache/hadoop/hive/metastore/api/ src/contrib/hive/metastore...
Date Fri, 19 Sep 2008 23:56:35 GMT
Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/gen-py/hive_metastore/ttypes.py
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/gen-py/hive_metastore/ttypes.py?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/gen-py/hive_metastore/ttypes.py (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/gen-py/hive_metastore/ttypes.py Fri Sep 19 16:56:30 2008
@@ -16,165 +16,14 @@
   fastbinary = None
 
 
-class MetaException(Exception):
-
-  thrift_spec = None
-  def __init__(self, d=None):
-    self.message = None
-    if isinstance(d, dict):
-      if 'message' in d:
-        self.message = d['message']
-
-  def read(self, iprot):
-    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-      return
-    iprot.readStructBegin()
-    while True:
-      (fname, ftype, fid) = iprot.readFieldBegin()
-      if ftype == TType.STOP:
-        break
-      if fid == -1:
-        if ftype == TType.STRING:
-          self.message = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      else:
-        iprot.skip(ftype)
-      iprot.readFieldEnd()
-    iprot.readStructEnd()
-
-  def write(self, oprot):
-    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-      return
-    oprot.writeStructBegin('MetaException')
-    if self.message != None:
-      oprot.writeFieldBegin('message', TType.STRING, -1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def __str__(self): 
-    return str(self.__dict__)
-
-  def __repr__(self): 
-    return repr(self.__dict__)
-
-  def __eq__(self, other):
-    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
-  def __ne__(self, other):
-    return not (self == other)
-
-class UnknownTableException(Exception):
-
-  thrift_spec = None
-  def __init__(self, d=None):
-    self.message = None
-    if isinstance(d, dict):
-      if 'message' in d:
-        self.message = d['message']
-
-  def read(self, iprot):
-    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-      return
-    iprot.readStructBegin()
-    while True:
-      (fname, ftype, fid) = iprot.readFieldBegin()
-      if ftype == TType.STOP:
-        break
-      if fid == -1:
-        if ftype == TType.STRING:
-          self.message = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      else:
-        iprot.skip(ftype)
-      iprot.readFieldEnd()
-    iprot.readStructEnd()
-
-  def write(self, oprot):
-    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-      return
-    oprot.writeStructBegin('UnknownTableException')
-    if self.message != None:
-      oprot.writeFieldBegin('message', TType.STRING, -1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def __str__(self): 
-    return str(self.__dict__)
-
-  def __repr__(self): 
-    return repr(self.__dict__)
-
-  def __eq__(self, other):
-    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
-  def __ne__(self, other):
-    return not (self == other)
-
-class UnknownDBException(Exception):
-
-  thrift_spec = None
-  def __init__(self, d=None):
-    self.message = None
-    if isinstance(d, dict):
-      if 'message' in d:
-        self.message = d['message']
-
-  def read(self, iprot):
-    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-      return
-    iprot.readStructBegin()
-    while True:
-      (fname, ftype, fid) = iprot.readFieldBegin()
-      if ftype == TType.STOP:
-        break
-      if fid == -1:
-        if ftype == TType.STRING:
-          self.message = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      else:
-        iprot.skip(ftype)
-      iprot.readFieldEnd()
-    iprot.readStructEnd()
-
-  def write(self, oprot):
-    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-      return
-    oprot.writeStructBegin('UnknownDBException')
-    if self.message != None:
-      oprot.writeFieldBegin('message', TType.STRING, -1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def __str__(self): 
-    return str(self.__dict__)
-
-  def __repr__(self): 
-    return repr(self.__dict__)
-
-  def __eq__(self, other):
-    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
-  def __ne__(self, other):
-    return not (self == other)
-
 class Version:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'version', None, None, ), # 1
+    (2, TType.STRING, 'comments', None, None, ), # 2
+  )
+
   def __init__(self, d=None):
     self.version = None
     self.comments = None
@@ -193,12 +42,12 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.version = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
           self.comments = iprot.readString();
         else:
@@ -214,11 +63,11 @@
       return
     oprot.writeStructBegin('Version')
     if self.version != None:
-      oprot.writeFieldBegin('version', TType.STRING, -1)
+      oprot.writeFieldBegin('version', TType.STRING, 1)
       oprot.writeString(self.version)
       oprot.writeFieldEnd()
     if self.comments != None:
-      oprot.writeFieldBegin('comments', TType.STRING, -2)
+      oprot.writeFieldBegin('comments', TType.STRING, 2)
       oprot.writeString(self.comments)
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
@@ -238,7 +87,13 @@
 
 class FieldSchema:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRING, 'type', None, None, ), # 2
+    (3, TType.STRING, 'comment', None, None, ), # 3
+  )
+
   def __init__(self, d=None):
     self.name = None
     self.type = None
@@ -260,17 +115,17 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.name = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
           self.type = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.comment = iprot.readString();
         else:
@@ -286,15 +141,15 @@
       return
     oprot.writeStructBegin('FieldSchema')
     if self.name != None:
-      oprot.writeFieldBegin('name', TType.STRING, -1)
+      oprot.writeFieldBegin('name', TType.STRING, 1)
       oprot.writeString(self.name)
       oprot.writeFieldEnd()
     if self.type != None:
-      oprot.writeFieldBegin('type', TType.STRING, -2)
+      oprot.writeFieldBegin('type', TType.STRING, 2)
       oprot.writeString(self.type)
       oprot.writeFieldEnd()
     if self.comment != None:
-      oprot.writeFieldBegin('comment', TType.STRING, -3)
+      oprot.writeFieldBegin('comment', TType.STRING, 3)
       oprot.writeString(self.comment)
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
@@ -314,7 +169,14 @@
 
 class Type:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRING, 'type1', None, None, ), # 2
+    (3, TType.STRING, 'type2', None, None, ), # 3
+    (4, TType.LIST, 'fields', (TType.STRUCT,(FieldSchema, FieldSchema.thrift_spec)), None, ), # 4
+  )
+
   def __init__(self, d=None):
     self.name = None
     self.type1 = None
@@ -339,22 +201,22 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.name = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
           self.type1 = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.type2 = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 4:
         if ftype == TType.LIST:
           self.fields = []
           (_etype3, _size0) = iprot.readListBegin()
@@ -376,19 +238,19 @@
       return
     oprot.writeStructBegin('Type')
     if self.name != None:
-      oprot.writeFieldBegin('name', TType.STRING, -1)
+      oprot.writeFieldBegin('name', TType.STRING, 1)
       oprot.writeString(self.name)
       oprot.writeFieldEnd()
     if self.type1 != None:
-      oprot.writeFieldBegin('type1', TType.STRING, -2)
+      oprot.writeFieldBegin('type1', TType.STRING, 2)
       oprot.writeString(self.type1)
       oprot.writeFieldEnd()
     if self.type2 != None:
-      oprot.writeFieldBegin('type2', TType.STRING, -3)
+      oprot.writeFieldBegin('type2', TType.STRING, 3)
       oprot.writeString(self.type2)
       oprot.writeFieldEnd()
     if self.fields != None:
-      oprot.writeFieldBegin('fields', TType.LIST, -4)
+      oprot.writeFieldBegin('fields', TType.LIST, 4)
       oprot.writeListBegin(TType.STRUCT, len(self.fields))
       for iter6 in self.fields:
         iter6.write(oprot)
@@ -411,15 +273,20 @@
 
 class Database:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRING, 'description', None, None, ), # 2
+  )
+
   def __init__(self, d=None):
     self.name = None
-    self.locationUri = None
+    self.description = None
     if isinstance(d, dict):
       if 'name' in d:
         self.name = d['name']
-      if 'locationUri' in d:
-        self.locationUri = d['locationUri']
+      if 'description' in d:
+        self.description = d['description']
 
   def read(self, iprot):
     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
@@ -430,14 +297,14 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.name = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
-          self.locationUri = iprot.readString();
+          self.description = iprot.readString();
         else:
           iprot.skip(ftype)
       else:
@@ -451,12 +318,12 @@
       return
     oprot.writeStructBegin('Database')
     if self.name != None:
-      oprot.writeFieldBegin('name', TType.STRING, -1)
+      oprot.writeFieldBegin('name', TType.STRING, 1)
       oprot.writeString(self.name)
       oprot.writeFieldEnd()
-    if self.locationUri != None:
-      oprot.writeFieldBegin('locationUri', TType.STRING, -2)
-      oprot.writeString(self.locationUri)
+    if self.description != None:
+      oprot.writeFieldBegin('description', TType.STRING, 2)
+      oprot.writeString(self.description)
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
@@ -475,34 +342,22 @@
 
 class SerDeInfo:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.STRING, 'serializationLib', None, None, ), # 2
+    (3, TType.MAP, 'parameters', (TType.STRING,None,TType.STRING,None), None, ), # 3
+  )
+
   def __init__(self, d=None):
     self.name = None
-    self.serializationFormat = None
-    self.serializationClass = None
     self.serializationLib = None
-    self.fieldDelim = None
-    self.collectionItemDelim = None
-    self.mapKeyDelim = None
-    self.lineDelim = None
     self.parameters = None
     if isinstance(d, dict):
       if 'name' in d:
         self.name = d['name']
-      if 'serializationFormat' in d:
-        self.serializationFormat = d['serializationFormat']
-      if 'serializationClass' in d:
-        self.serializationClass = d['serializationClass']
       if 'serializationLib' in d:
         self.serializationLib = d['serializationLib']
-      if 'fieldDelim' in d:
-        self.fieldDelim = d['fieldDelim']
-      if 'collectionItemDelim' in d:
-        self.collectionItemDelim = d['collectionItemDelim']
-      if 'mapKeyDelim' in d:
-        self.mapKeyDelim = d['mapKeyDelim']
-      if 'lineDelim' in d:
-        self.lineDelim = d['lineDelim']
       if 'parameters' in d:
         self.parameters = d['parameters']
 
@@ -515,47 +370,17 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.name = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
-        if ftype == TType.STRING:
-          self.serializationFormat = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -3:
-        if ftype == TType.STRING:
-          self.serializationClass = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 2:
         if ftype == TType.STRING:
           self.serializationLib = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -5:
-        if ftype == TType.STRING:
-          self.fieldDelim = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -6:
-        if ftype == TType.STRING:
-          self.collectionItemDelim = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -7:
-        if ftype == TType.STRING:
-          self.mapKeyDelim = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -8:
-        if ftype == TType.STRING:
-          self.lineDelim = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == -9:
+      elif fid == 3:
         if ftype == TType.MAP:
           self.parameters = {}
           (_ktype8, _vtype9, _size7 ) = iprot.readMapBegin() 
@@ -577,39 +402,15 @@
       return
     oprot.writeStructBegin('SerDeInfo')
     if self.name != None:
-      oprot.writeFieldBegin('name', TType.STRING, -1)
+      oprot.writeFieldBegin('name', TType.STRING, 1)
       oprot.writeString(self.name)
       oprot.writeFieldEnd()
-    if self.serializationFormat != None:
-      oprot.writeFieldBegin('serializationFormat', TType.STRING, -2)
-      oprot.writeString(self.serializationFormat)
-      oprot.writeFieldEnd()
-    if self.serializationClass != None:
-      oprot.writeFieldBegin('serializationClass', TType.STRING, -3)
-      oprot.writeString(self.serializationClass)
-      oprot.writeFieldEnd()
     if self.serializationLib != None:
-      oprot.writeFieldBegin('serializationLib', TType.STRING, -4)
+      oprot.writeFieldBegin('serializationLib', TType.STRING, 2)
       oprot.writeString(self.serializationLib)
       oprot.writeFieldEnd()
-    if self.fieldDelim != None:
-      oprot.writeFieldBegin('fieldDelim', TType.STRING, -5)
-      oprot.writeString(self.fieldDelim)
-      oprot.writeFieldEnd()
-    if self.collectionItemDelim != None:
-      oprot.writeFieldBegin('collectionItemDelim', TType.STRING, -6)
-      oprot.writeString(self.collectionItemDelim)
-      oprot.writeFieldEnd()
-    if self.mapKeyDelim != None:
-      oprot.writeFieldBegin('mapKeyDelim', TType.STRING, -7)
-      oprot.writeString(self.mapKeyDelim)
-      oprot.writeFieldEnd()
-    if self.lineDelim != None:
-      oprot.writeFieldBegin('lineDelim', TType.STRING, -8)
-      oprot.writeString(self.lineDelim)
-      oprot.writeFieldEnd()
     if self.parameters != None:
-      oprot.writeFieldBegin('parameters', TType.MAP, -9)
+      oprot.writeFieldBegin('parameters', TType.MAP, 3)
       oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.parameters))
       for kiter14,viter15 in self.parameters.items():
         oprot.writeString(kiter14)
@@ -633,7 +434,12 @@
 
 class Order:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'col', None, None, ), # 1
+    (2, TType.I32, 'order', None, None, ), # 2
+  )
+
   def __init__(self, d=None):
     self.col = None
     self.order = None
@@ -652,12 +458,12 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.col = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.I32:
           self.order = iprot.readI32();
         else:
@@ -673,11 +479,11 @@
       return
     oprot.writeStructBegin('Order')
     if self.col != None:
-      oprot.writeFieldBegin('col', TType.STRING, -1)
+      oprot.writeFieldBegin('col', TType.STRING, 1)
       oprot.writeString(self.col)
       oprot.writeFieldEnd()
     if self.order != None:
-      oprot.writeFieldBegin('order', TType.I32, -2)
+      oprot.writeFieldBegin('order', TType.I32, 2)
       oprot.writeI32(self.order)
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
@@ -697,13 +503,26 @@
 
 class StorageDescriptor:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.LIST, 'cols', (TType.STRUCT,(FieldSchema, FieldSchema.thrift_spec)), None, ), # 1
+    (2, TType.STRING, 'location', None, None, ), # 2
+    (3, TType.STRING, 'inputFormat', None, None, ), # 3
+    (4, TType.STRING, 'outputFormat', None, None, ), # 4
+    (5, TType.BOOL, 'compressed', None, None, ), # 5
+    (6, TType.I32, 'numBuckets', None, None, ), # 6
+    (7, TType.STRUCT, 'serdeInfo', (SerDeInfo, SerDeInfo.thrift_spec), None, ), # 7
+    (8, TType.LIST, 'bucketCols', (TType.STRING,None), None, ), # 8
+    (9, TType.LIST, 'sortCols', (TType.STRUCT,(Order, Order.thrift_spec)), None, ), # 9
+    (10, TType.MAP, 'parameters', (TType.STRING,None,TType.STRING,None), None, ), # 10
+  )
+
   def __init__(self, d=None):
     self.cols = None
     self.location = None
     self.inputFormat = None
     self.outputFormat = None
-    self.isCompressed = None
+    self.compressed = None
     self.numBuckets = 32
     self.serdeInfo = None
     self.bucketCols = None
@@ -718,8 +537,8 @@
         self.inputFormat = d['inputFormat']
       if 'outputFormat' in d:
         self.outputFormat = d['outputFormat']
-      if 'isCompressed' in d:
-        self.isCompressed = d['isCompressed']
+      if 'compressed' in d:
+        self.compressed = d['compressed']
       if 'numBuckets' in d:
         self.numBuckets = d['numBuckets']
       if 'serdeInfo' in d:
@@ -740,7 +559,7 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.LIST:
           self.cols = []
           (_etype19, _size16) = iprot.readListBegin()
@@ -751,38 +570,38 @@
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
           self.location = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.inputFormat = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 4:
         if ftype == TType.STRING:
           self.outputFormat = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -5:
+      elif fid == 5:
         if ftype == TType.BOOL:
-          self.isCompressed = iprot.readBool();
+          self.compressed = iprot.readBool();
         else:
           iprot.skip(ftype)
-      elif fid == -6:
+      elif fid == 6:
         if ftype == TType.I32:
           self.numBuckets = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -7:
+      elif fid == 7:
         if ftype == TType.STRUCT:
           self.serdeInfo = SerDeInfo()
           self.serdeInfo.read(iprot)
         else:
           iprot.skip(ftype)
-      elif fid == -8:
+      elif fid == 8:
         if ftype == TType.LIST:
           self.bucketCols = []
           (_etype25, _size22) = iprot.readListBegin()
@@ -792,7 +611,7 @@
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
-      elif fid == -9:
+      elif fid == 9:
         if ftype == TType.LIST:
           self.sortCols = []
           (_etype31, _size28) = iprot.readListBegin()
@@ -803,7 +622,7 @@
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
-      elif fid == -10:
+      elif fid == 10:
         if ftype == TType.MAP:
           self.parameters = {}
           (_ktype35, _vtype36, _size34 ) = iprot.readMapBegin() 
@@ -825,52 +644,52 @@
       return
     oprot.writeStructBegin('StorageDescriptor')
     if self.cols != None:
-      oprot.writeFieldBegin('cols', TType.LIST, -1)
+      oprot.writeFieldBegin('cols', TType.LIST, 1)
       oprot.writeListBegin(TType.STRUCT, len(self.cols))
       for iter41 in self.cols:
         iter41.write(oprot)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.location != None:
-      oprot.writeFieldBegin('location', TType.STRING, -2)
+      oprot.writeFieldBegin('location', TType.STRING, 2)
       oprot.writeString(self.location)
       oprot.writeFieldEnd()
     if self.inputFormat != None:
-      oprot.writeFieldBegin('inputFormat', TType.STRING, -3)
+      oprot.writeFieldBegin('inputFormat', TType.STRING, 3)
       oprot.writeString(self.inputFormat)
       oprot.writeFieldEnd()
     if self.outputFormat != None:
-      oprot.writeFieldBegin('outputFormat', TType.STRING, -4)
+      oprot.writeFieldBegin('outputFormat', TType.STRING, 4)
       oprot.writeString(self.outputFormat)
       oprot.writeFieldEnd()
-    if self.isCompressed != None:
-      oprot.writeFieldBegin('isCompressed', TType.BOOL, -5)
-      oprot.writeBool(self.isCompressed)
+    if self.compressed != None:
+      oprot.writeFieldBegin('compressed', TType.BOOL, 5)
+      oprot.writeBool(self.compressed)
       oprot.writeFieldEnd()
     if self.numBuckets != None:
-      oprot.writeFieldBegin('numBuckets', TType.I32, -6)
+      oprot.writeFieldBegin('numBuckets', TType.I32, 6)
       oprot.writeI32(self.numBuckets)
       oprot.writeFieldEnd()
     if self.serdeInfo != None:
-      oprot.writeFieldBegin('serdeInfo', TType.STRUCT, -7)
+      oprot.writeFieldBegin('serdeInfo', TType.STRUCT, 7)
       self.serdeInfo.write(oprot)
       oprot.writeFieldEnd()
     if self.bucketCols != None:
-      oprot.writeFieldBegin('bucketCols', TType.LIST, -8)
+      oprot.writeFieldBegin('bucketCols', TType.LIST, 8)
       oprot.writeListBegin(TType.STRING, len(self.bucketCols))
       for iter42 in self.bucketCols:
         oprot.writeString(iter42)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.sortCols != None:
-      oprot.writeFieldBegin('sortCols', TType.LIST, -9)
+      oprot.writeFieldBegin('sortCols', TType.LIST, 9)
       oprot.writeListBegin(TType.STRUCT, len(self.sortCols))
       for iter43 in self.sortCols:
         iter43.write(oprot)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.parameters != None:
-      oprot.writeFieldBegin('parameters', TType.MAP, -10)
+      oprot.writeFieldBegin('parameters', TType.MAP, 10)
       oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.parameters))
       for kiter44,viter45 in self.parameters.items():
         oprot.writeString(kiter44)
@@ -894,10 +713,22 @@
 
 class Table:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'tableName', None, None, ), # 1
+    (2, TType.STRING, 'dbName', None, None, ), # 2
+    (3, TType.STRING, 'owner', None, None, ), # 3
+    (4, TType.I32, 'createTime', None, None, ), # 4
+    (5, TType.I32, 'lastAccessTime', None, None, ), # 5
+    (6, TType.I32, 'retention', None, None, ), # 6
+    (7, TType.STRUCT, 'sd', (StorageDescriptor, StorageDescriptor.thrift_spec), None, ), # 7
+    (8, TType.LIST, 'partitionKeys', (TType.STRUCT,(FieldSchema, FieldSchema.thrift_spec)), None, ), # 8
+    (9, TType.MAP, 'parameters', (TType.STRING,None,TType.STRING,None), None, ), # 9
+  )
+
   def __init__(self, d=None):
     self.tableName = None
-    self.database = None
+    self.dbName = None
     self.owner = None
     self.createTime = None
     self.lastAccessTime = None
@@ -908,8 +739,8 @@
     if isinstance(d, dict):
       if 'tableName' in d:
         self.tableName = d['tableName']
-      if 'database' in d:
-        self.database = d['database']
+      if 'dbName' in d:
+        self.dbName = d['dbName']
       if 'owner' in d:
         self.owner = d['owner']
       if 'createTime' in d:
@@ -934,43 +765,43 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.tableName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
-          self.database = iprot.readString();
+          self.dbName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.owner = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 4:
         if ftype == TType.I32:
           self.createTime = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -5:
+      elif fid == 5:
         if ftype == TType.I32:
           self.lastAccessTime = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -6:
+      elif fid == 6:
         if ftype == TType.I32:
           self.retention = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -7:
+      elif fid == 7:
         if ftype == TType.STRUCT:
           self.sd = StorageDescriptor()
           self.sd.read(iprot)
         else:
           iprot.skip(ftype)
-      elif fid == -8:
+      elif fid == 8:
         if ftype == TType.LIST:
           self.partitionKeys = []
           (_etype49, _size46) = iprot.readListBegin()
@@ -981,7 +812,7 @@
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
-      elif fid == -9:
+      elif fid == 9:
         if ftype == TType.MAP:
           self.parameters = {}
           (_ktype53, _vtype54, _size52 ) = iprot.readMapBegin() 
@@ -1003,42 +834,42 @@
       return
     oprot.writeStructBegin('Table')
     if self.tableName != None:
-      oprot.writeFieldBegin('tableName', TType.STRING, -1)
+      oprot.writeFieldBegin('tableName', TType.STRING, 1)
       oprot.writeString(self.tableName)
       oprot.writeFieldEnd()
-    if self.database != None:
-      oprot.writeFieldBegin('database', TType.STRING, -2)
-      oprot.writeString(self.database)
+    if self.dbName != None:
+      oprot.writeFieldBegin('dbName', TType.STRING, 2)
+      oprot.writeString(self.dbName)
       oprot.writeFieldEnd()
     if self.owner != None:
-      oprot.writeFieldBegin('owner', TType.STRING, -3)
+      oprot.writeFieldBegin('owner', TType.STRING, 3)
       oprot.writeString(self.owner)
       oprot.writeFieldEnd()
     if self.createTime != None:
-      oprot.writeFieldBegin('createTime', TType.I32, -4)
+      oprot.writeFieldBegin('createTime', TType.I32, 4)
       oprot.writeI32(self.createTime)
       oprot.writeFieldEnd()
     if self.lastAccessTime != None:
-      oprot.writeFieldBegin('lastAccessTime', TType.I32, -5)
+      oprot.writeFieldBegin('lastAccessTime', TType.I32, 5)
       oprot.writeI32(self.lastAccessTime)
       oprot.writeFieldEnd()
     if self.retention != None:
-      oprot.writeFieldBegin('retention', TType.I32, -6)
+      oprot.writeFieldBegin('retention', TType.I32, 6)
       oprot.writeI32(self.retention)
       oprot.writeFieldEnd()
     if self.sd != None:
-      oprot.writeFieldBegin('sd', TType.STRUCT, -7)
+      oprot.writeFieldBegin('sd', TType.STRUCT, 7)
       self.sd.write(oprot)
       oprot.writeFieldEnd()
     if self.partitionKeys != None:
-      oprot.writeFieldBegin('partitionKeys', TType.LIST, -8)
+      oprot.writeFieldBegin('partitionKeys', TType.LIST, 8)
       oprot.writeListBegin(TType.STRUCT, len(self.partitionKeys))
       for iter59 in self.partitionKeys:
         iter59.write(oprot)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.parameters != None:
-      oprot.writeFieldBegin('parameters', TType.MAP, -9)
+      oprot.writeFieldBegin('parameters', TType.MAP, 9)
       oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.parameters))
       for kiter60,viter61 in self.parameters.items():
         oprot.writeString(kiter60)
@@ -1062,10 +893,20 @@
 
 class Partition:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.LIST, 'values', (TType.STRING,None), None, ), # 1
+    (2, TType.STRING, 'dbName', None, None, ), # 2
+    (3, TType.STRING, 'tableName', None, None, ), # 3
+    (4, TType.I32, 'createTime', None, None, ), # 4
+    (5, TType.I32, 'lastAccessTime', None, None, ), # 5
+    (6, TType.STRUCT, 'sd', (StorageDescriptor, StorageDescriptor.thrift_spec), None, ), # 6
+    (7, TType.MAP, 'parameters', (TType.STRING,None,TType.STRING,None), None, ), # 7
+  )
+
   def __init__(self, d=None):
     self.values = None
-    self.database = None
+    self.dbName = None
     self.tableName = None
     self.createTime = None
     self.lastAccessTime = None
@@ -1074,8 +915,8 @@
     if isinstance(d, dict):
       if 'values' in d:
         self.values = d['values']
-      if 'database' in d:
-        self.database = d['database']
+      if 'dbName' in d:
+        self.dbName = d['dbName']
       if 'tableName' in d:
         self.tableName = d['tableName']
       if 'createTime' in d:
@@ -1096,7 +937,7 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.LIST:
           self.values = []
           (_etype65, _size62) = iprot.readListBegin()
@@ -1106,33 +947,33 @@
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.STRING:
-          self.database = iprot.readString();
+          self.dbName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.tableName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 4:
         if ftype == TType.I32:
           self.createTime = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -5:
+      elif fid == 5:
         if ftype == TType.I32:
           self.lastAccessTime = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -6:
+      elif fid == 6:
         if ftype == TType.STRUCT:
           self.sd = StorageDescriptor()
           self.sd.read(iprot)
         else:
           iprot.skip(ftype)
-      elif fid == -7:
+      elif fid == 7:
         if ftype == TType.MAP:
           self.parameters = {}
           (_ktype69, _vtype70, _size68 ) = iprot.readMapBegin() 
@@ -1154,34 +995,34 @@
       return
     oprot.writeStructBegin('Partition')
     if self.values != None:
-      oprot.writeFieldBegin('values', TType.LIST, -1)
+      oprot.writeFieldBegin('values', TType.LIST, 1)
       oprot.writeListBegin(TType.STRING, len(self.values))
       for iter75 in self.values:
         oprot.writeString(iter75)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
-    if self.database != None:
-      oprot.writeFieldBegin('database', TType.STRING, -2)
-      oprot.writeString(self.database)
+    if self.dbName != None:
+      oprot.writeFieldBegin('dbName', TType.STRING, 2)
+      oprot.writeString(self.dbName)
       oprot.writeFieldEnd()
     if self.tableName != None:
-      oprot.writeFieldBegin('tableName', TType.STRING, -3)
+      oprot.writeFieldBegin('tableName', TType.STRING, 3)
       oprot.writeString(self.tableName)
       oprot.writeFieldEnd()
     if self.createTime != None:
-      oprot.writeFieldBegin('createTime', TType.I32, -4)
+      oprot.writeFieldBegin('createTime', TType.I32, 4)
       oprot.writeI32(self.createTime)
       oprot.writeFieldEnd()
     if self.lastAccessTime != None:
-      oprot.writeFieldBegin('lastAccessTime', TType.I32, -5)
+      oprot.writeFieldBegin('lastAccessTime', TType.I32, 5)
       oprot.writeI32(self.lastAccessTime)
       oprot.writeFieldEnd()
     if self.sd != None:
-      oprot.writeFieldBegin('sd', TType.STRUCT, -6)
+      oprot.writeFieldBegin('sd', TType.STRUCT, 6)
       self.sd.write(oprot)
       oprot.writeFieldEnd()
     if self.parameters != None:
-      oprot.writeFieldBegin('parameters', TType.MAP, -7)
+      oprot.writeFieldBegin('parameters', TType.MAP, 7)
       oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.parameters))
       for kiter76,viter77 in self.parameters.items():
         oprot.writeString(kiter76)
@@ -1205,12 +1046,20 @@
 
 class Index:
 
-  thrift_spec = None
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'indexName', None, None, ), # 1
+    (2, TType.I32, 'indexType', None, None, ), # 2
+    (3, TType.STRING, 'tableName', None, None, ), # 3
+    (4, TType.STRING, 'dbName', None, None, ), # 4
+    (5, TType.LIST, 'colNames', (TType.STRING,None), None, ), # 5
+  )
+
   def __init__(self, d=None):
     self.indexName = None
     self.indexType = None
     self.tableName = None
-    self.databaseName = None
+    self.dbName = None
     self.colNames = None
     if isinstance(d, dict):
       if 'indexName' in d:
@@ -1219,8 +1068,8 @@
         self.indexType = d['indexType']
       if 'tableName' in d:
         self.tableName = d['tableName']
-      if 'databaseName' in d:
-        self.databaseName = d['databaseName']
+      if 'dbName' in d:
+        self.dbName = d['dbName']
       if 'colNames' in d:
         self.colNames = d['colNames']
 
@@ -1233,27 +1082,27 @@
       (fname, ftype, fid) = iprot.readFieldBegin()
       if ftype == TType.STOP:
         break
-      if fid == -1:
+      if fid == 1:
         if ftype == TType.STRING:
           self.indexName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -2:
+      elif fid == 2:
         if ftype == TType.I32:
           self.indexType = iprot.readI32();
         else:
           iprot.skip(ftype)
-      elif fid == -3:
+      elif fid == 3:
         if ftype == TType.STRING:
           self.tableName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -4:
+      elif fid == 4:
         if ftype == TType.STRING:
-          self.databaseName = iprot.readString();
+          self.dbName = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == -5:
+      elif fid == 5:
         if ftype == TType.LIST:
           self.colNames = []
           (_etype81, _size78) = iprot.readListBegin()
@@ -1274,23 +1123,23 @@
       return
     oprot.writeStructBegin('Index')
     if self.indexName != None:
-      oprot.writeFieldBegin('indexName', TType.STRING, -1)
+      oprot.writeFieldBegin('indexName', TType.STRING, 1)
       oprot.writeString(self.indexName)
       oprot.writeFieldEnd()
     if self.indexType != None:
-      oprot.writeFieldBegin('indexType', TType.I32, -2)
+      oprot.writeFieldBegin('indexType', TType.I32, 2)
       oprot.writeI32(self.indexType)
       oprot.writeFieldEnd()
     if self.tableName != None:
-      oprot.writeFieldBegin('tableName', TType.STRING, -3)
+      oprot.writeFieldBegin('tableName', TType.STRING, 3)
       oprot.writeString(self.tableName)
       oprot.writeFieldEnd()
-    if self.databaseName != None:
-      oprot.writeFieldBegin('databaseName', TType.STRING, -4)
-      oprot.writeString(self.databaseName)
+    if self.dbName != None:
+      oprot.writeFieldBegin('dbName', TType.STRING, 4)
+      oprot.writeString(self.dbName)
       oprot.writeFieldEnd()
     if self.colNames != None:
-      oprot.writeFieldBegin('colNames', TType.LIST, -5)
+      oprot.writeFieldBegin('colNames', TType.LIST, 5)
       oprot.writeListBegin(TType.STRING, len(self.colNames))
       for iter84 in self.colNames:
         oprot.writeString(iter84)
@@ -1311,6 +1160,162 @@
   def __ne__(self, other):
     return not (self == other)
 
+class MetaException(Exception):
+
+  thrift_spec = None
+  def __init__(self, d=None):
+    self.message = None
+    if isinstance(d, dict):
+      if 'message' in d:
+        self.message = d['message']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == -1:
+        if ftype == TType.STRING:
+          self.message = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('MetaException')
+    if self.message != None:
+      oprot.writeFieldBegin('message', TType.STRING, -1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class UnknownTableException(Exception):
+
+  thrift_spec = None
+  def __init__(self, d=None):
+    self.message = None
+    if isinstance(d, dict):
+      if 'message' in d:
+        self.message = d['message']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == -1:
+        if ftype == TType.STRING:
+          self.message = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('UnknownTableException')
+    if self.message != None:
+      oprot.writeFieldBegin('message', TType.STRING, -1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class UnknownDBException(Exception):
+
+  thrift_spec = None
+  def __init__(self, d=None):
+    self.message = None
+    if isinstance(d, dict):
+      if 'message' in d:
+        self.message = d['message']
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == -1:
+        if ftype == TType.STRING:
+          self.message = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('UnknownDBException')
+    if self.message != None:
+      oprot.writeFieldBegin('message', TType.STRING, -1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __str__(self): 
+    return str(self.__dict__)
+
+  def __repr__(self): 
+    return repr(self.__dict__)
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
 class AlreadyExistsException(Exception):
 
   thrift_spec = None

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/FileStore.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/FileStore.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/FileStore.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/FileStore.java Fri Sep 19 16:56:30 2008
@@ -303,7 +303,7 @@
   public void createTable(Table tbl) throws InvalidObjectException, MetaException {
     Properties p = MetaStoreUtils.getSchema(tbl);
     try {
-      DB db = new DB(tbl.getDatabase(), conf);
+      DB db = new DB(tbl.getDbName(), conf);
       RWTable.create(db, tbl.getTableName(), p, conf);
     } catch (UnknownDBException e) {
       throw new InvalidObjectException(e.getMessage());
@@ -325,7 +325,7 @@
   public Table getTable(String dbName, String tableName) throws MetaException {
     try {
       Properties p = new DB(dbName, conf).getTable(tableName, true).getSchema();
-      return MetaStoreUtils.getTable(p);
+      return MetaStoreUtils.getTable(conf, p);
     } catch (Exception e) {
       LOG.error(StringUtils.stringifyException(e));
       throw new MetaException(e.getMessage());
@@ -392,4 +392,11 @@
     // no-op
   }
 
+  @Override
+  public List<String> listPartitionNames(String db_name, String tbl_name, short max_parts)
+      throws MetaException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
 };

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Fri Sep 19 16:56:30 2008
@@ -19,11 +19,8 @@
 package org.apache.hadoop.hive.metastore;
 
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,9 +43,8 @@
 import org.apache.hadoop.hive.metastore.api.Type;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 import org.apache.hadoop.hive.metastore.api.UnknownTableException;
-import org.apache.hadoop.hive.serde.SerDe;
-import org.apache.hadoop.hive.serde.SerDeException;
-import org.apache.hadoop.hive.serde.SerDeField;
+import org.apache.hadoop.hive.serde2.Deserializer;
+import org.apache.hadoop.hive.serde2.SerDeException;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
 
@@ -64,7 +60,7 @@
 import com.facebook.thrift.transport.TTransportFactory;
 
 /**
- * TODO:pc remove application logic to a separate interface. rename to MetaStoreServer
+ * TODO:pc remove application logic to a separate interface. 
  */
 public class HiveMetaStore extends ThriftHiveMetastore {
   
@@ -271,7 +267,7 @@
 
       public void create_table(Table tbl) throws AlreadyExistsException, MetaException, InvalidObjectException {
         this.incrementCounter("create_table");
-        logStartFunction("create_table: db=" + tbl.getDatabase() + " tbl=" + tbl.getTableName());
+        logStartFunction("create_table: db=" + tbl.getDbName() + " tbl=" + tbl.getTableName());
         boolean success = false;
         if(!MetaStoreUtils.validateName(tbl.getTableName())) {
           throw new InvalidObjectException(tbl.getTableName() + " is not a valid object name");
@@ -280,17 +276,14 @@
           getMS().openTransaction();
           Path tblPath = null;
           if(tbl.getSd().getLocation() == null || tbl.getSd().getLocation().isEmpty()) {
-            tblPath = wh.getDefaultTablePath(tbl.getDatabase(), tbl.getTableName());
+            tblPath = wh.getDefaultTablePath(tbl.getDbName(), tbl.getTableName());
             tbl.getSd().setLocation(tblPath.toString());
           } else {
             tblPath = new Path(tbl.getSd().getLocation());
           }
           // get_table checks whether database exists, it should be moved here
-          try {
-            if(get_table(tbl.getDatabase(), tbl.getTableName()) != null) {
-              throw new AlreadyExistsException("Table " + tbl.getTableName() + " already exists");
-            }
-          } catch (NoSuchObjectException e) {
+          if(is_table_exists(tbl.getDbName(), tbl.getTableName())) {
+            throw new AlreadyExistsException("Table " + tbl.getTableName() + " already exists");
           }
           getMS().createTable(tbl);
           if(wh.mkdirs(tblPath)) {
@@ -304,6 +297,14 @@
         }
       }
       
+      public boolean is_table_exists(String dbname, String name) throws MetaException {
+        try {
+          return (get_table(dbname, name) != null);
+        } catch (NoSuchObjectException e) {
+          return false;
+        }
+      }
+      
       public void drop_table(String dbname, String name, boolean deleteData) throws NoSuchObjectException, MetaException {
         this.incrementCounter("drop_table");
         logStartFunction("drop_table", dbname, name);
@@ -362,16 +363,16 @@
         try {
           getMS().openTransaction();
           part = new Partition();
-          part.setDatabase(dbName);
+          part.setDbName(dbName);
           part.setTableName(tableName);
           part.setValues(part_vals);
 
-          Partition old_part = this.get_partition(part.getDatabase(), part.getTableName(), part.getValues());
+          Partition old_part = this.get_partition(part.getDbName(), part.getTableName(), part.getValues());
           if( old_part != null) {
             throw new AlreadyExistsException("Partition already exists:" + part);
           }
           
-          Table tbl = getMS().getTable(part.getDatabase(), part.getTableName());
+          Table tbl = getMS().getTable(part.getDbName(), part.getTableName());
           if(tbl == null) {
             throw new InvalidObjectException("Unable to add partition because table or database do not exist");
           }
@@ -393,19 +394,43 @@
         }
         return part;
       }
+      
+      public int add_partitions(List<Partition> parts) throws MetaException, InvalidObjectException, AlreadyExistsException {
+        this.incrementCounter("add_partition");
+        if(parts.size() == 0) {
+          return 0;
+        }
+        String db = parts.get(0).getDbName();
+        String tbl = parts.get(0).getTableName();
+        logStartFunction("add_partitions", db, tbl);
+        boolean success = false;
+        try {
+          getMS().openTransaction();
+          for (Partition part : parts) {
+            this.add_partition(part);
+          }
+          success = true;
+          getMS().commitTransaction();
+        } finally {
+          if(!success) {
+            getMS().rollbackTransaction();
+          }
+        }
+        return parts.size();
+      }
 
       public Partition add_partition(Partition part) throws InvalidObjectException,
           AlreadyExistsException, MetaException {
         this.incrementCounter("add_partition");
-        logStartFunction("add_partition", part.getDatabase(), part.getTableName());
+        logStartFunction("add_partition", part.getDbName(), part.getTableName());
         boolean success = false;
         try {
           getMS().openTransaction();
-          Partition old_part = this.get_partition(part.getDatabase(), part.getTableName(), part.getValues());
+          Partition old_part = this.get_partition(part.getDbName(), part.getTableName(), part.getValues());
           if( old_part != null) {
             throw new AlreadyExistsException("Partition already exists:" + part);
           }
-          Table tbl = getMS().getTable(part.getDatabase(), part.getTableName());
+          Table tbl = getMS().getTable(part.getDbName(), part.getTableName());
           if(tbl == null) {
             throw new InvalidObjectException("Unable to add partition because table or database do not exist");
           }
@@ -446,6 +471,12 @@
         logStartFunction("get_partitions", db_name, tbl_name);
         return getMS().getPartitions(db_name, tbl_name, max_parts);
       }
+      
+      public List<String> get_partition_names(String db_name, String tbl_name, short max_parts) throws MetaException {
+        this.incrementCounter("get_partition_names");
+        logStartFunction("get_partition_names", db_name, tbl_name);
+        return getMS().listPartitionNames(db_name, tbl_name, max_parts);
+      }
 
       public boolean alter_partitions(StorageDescriptor sd, List<String> parts) throws InvalidOperationException,
           MetaException {
@@ -491,90 +522,19 @@
       }
 
       @Override
-      public List<String> cat(String db_name, String table_name, String partition, int high)
-          throws MetaException, UnknownDBException, UnknownTableException {
-        this.incrementCounter("cat");
-        logStartFunction("cat: db=" + db_name + " tbl=" + table_name + " part=" + partition + " high=" + high);
-        // TODO Auto-generated method stub
-        throw new MetaException("Not implemented. Please use select * query instead");
-      }
-
-      @Override
       public List<String> get_tables(String dbname, String pattern) throws MetaException {
         this.incrementCounter("get_tables");
         logStartFunction("get_tables: db=" + dbname + " pat=" + pattern);
         return getMS().getTables(dbname, pattern);
       }
 
-      @Override
-      public void truncate_table(String db_name, String table_name, String partition)
-          throws MetaException, UnknownTableException, UnknownDBException {
-        // TODO Auto-generated method stub
-        this.incrementCounter("truncate_table");
-        logStartFunction("truncate_table: db=" + db_name + " tbl=" + table_name);
-      }
-      
-      /**
-       * normalizeType
-       *
-       * For pretty printing
-       *
-       * @param type a type name
-       * @return cleaned up - remove Java.lang and make numbers into int , ...
-       */
-      public String normalizeType(String type) {
-        Pattern tpat = Pattern.compile("java.lang.");
-        Matcher m = tpat.matcher(type);
-        type = m.replaceFirst("");
-        String ret = type;
-        if(type.equals("String")) {
-          ret = "string";
-        }  else if(type.equals("Integer")) {
-          ret = "int";
-        }
-        return ret;
-
-      }
-
-      /**
-       * hfToStrting
-       *
-       * Converts a basic SerDe's type to a string. It doesn't do any recursion.
-       *
-       * @param f the hive field - cannot be null!
-       * @return a string representation of the field's type
-       * @exception MetaException - if the SerDe raises it or the field is null
-       *
-       */
-      private String hfToString(SerDeField f) throws MetaException {
-        String ret;
-
-        try {
-          if(f.isPrimitive()) {
-            ret = this.normalizeType(f.getType().getName());
-          } else if(f.isList()) {
-            ret = "List<" +  this.normalizeType(f.getListElementType().getName()) + ">";
-          } else if(f.isMap()) {
-            ret = "Map<" + this.normalizeType(f.getMapKeyType().getName()) + "," +
-              this.normalizeType(f.getMapValueType().getName()) + ">";
-          } else {
-            // complex type and we just show the type name of the complex type
-            ret = f.getName();
-          }
-        }  catch(Exception e) {
-          StringUtils.stringifyException(e);
-          throw new MetaException(e.getMessage());
-        }
-        return ret;
-      }
 
-      public ArrayList<FieldSchema> get_fields(String db, String tableName) throws MetaException,UnknownTableException, UnknownDBException {
+      public List<FieldSchema> get_fields(String db, String tableName) 
+        throws MetaException,UnknownTableException, UnknownDBException {
         this.incrementCounter("get_fields");
         logStartFunction("get_fields: db=" + db + "tbl=" + tableName);
-        ArrayList<FieldSchema> str_fields = new ArrayList<FieldSchema>();
         String [] names = tableName.split("\\.");
         String base_table_name = names[0];
-        List<SerDeField> hive_fields = new ArrayList<SerDeField>();
 
         Table tbl;
         try {
@@ -582,39 +542,9 @@
         } catch (NoSuchObjectException e) {
           throw new UnknownTableException(e.getMessage());
         }
-        SerDeField hf = null;
         try {
-          // TODO:pc getSerDe requires 'columns' field in some cases and this doesn't supply
-          SerDe s = MetaStoreUtils.getSerDe(this.hiveConf, tbl);
-
-          // recurse down the type.subtype.subsubtype expression until at the desired type
-          for(int i =  1; i < names.length; i++) {
-            hf = s.getFieldFromExpression(hf,names[i]);
-          }
-
-          // rules on how to recurse the SerDe based on its type
-          if(hf != null && hf.isPrimitive()) {
-            hive_fields.add(hf);
-          } else if(hf != null && hf.isList()) {
-            // don't remember why added this rule??
-            // should just be a hive_fields.add(hf)
-            try {
-              hive_fields = s.getFields(hf);
-            } catch(Exception e) {
-              hive_fields.add(hf);
-            }
-          } else if(hf != null && hf.isMap()) {
-            hive_fields.add(hf);
-          } else {
-            hive_fields = s.getFields(hf);
-          }
-
-          for(SerDeField field: hive_fields) {
-            String name = field.getName();
-            String schema = this.hfToString(field);
-            str_fields.add(new FieldSchema(name, schema, "automatically generated"));
-          }
-          return str_fields;
+          Deserializer s = MetaStoreUtils.getDeserializer(this.hiveConf, tbl);
+          return MetaStoreUtils.getFieldsFromDeserializer(tableName, s);
         } catch(SerDeException e) {
           StringUtils.stringifyException(e);
           throw new MetaException(e.getMessage());

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java Fri Sep 19 16:56:30 2008
@@ -20,31 +20,24 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
-import org.apache.hadoop.hive.metastore.api.Constants;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.ExistingDependentsException;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
 import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore;
 import org.apache.hadoop.hive.metastore.api.Type;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
-import org.apache.hadoop.hive.metastore.api.UnknownTableException;
 
 import com.facebook.thrift.TException;
 import com.facebook.thrift.protocol.TBinaryProtocol;
@@ -54,8 +47,7 @@
 import com.facebook.thrift.transport.TTransportException;
 
 /**
- * Metastore Client.
- * TODO: rename this as MetaStoreClient and remove the interface as it is not needed 
+ * Hive Metastore Client.
  */
 public class HiveMetaStoreClient implements IMetaStoreClient {
   ThriftHiveMetastore.Iface client = null;
@@ -451,70 +443,6 @@
     return client.get_type(name);
   }
 
-  @SuppressWarnings("unused")
-  // Will be removed after testing
-  private void createTable(String tableName, Properties schema) throws MetaException,
-      UnknownTableException, TException {
-    Table t = new Table();
-    t.setSd(new StorageDescriptor());
-    t.setTableName(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.META_TABLE_NAME));
-    t.getSd().setLocation(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.META_TABLE_LOCATION));
-    t.getSd().setInputFormat(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.FILE_INPUT_FORMAT,
-          org.apache.hadoop.mapred.SequenceFileInputFormat.class.getName())); 
-    t.getSd().setOutputFormat(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.FILE_OUTPUT_FORMAT,
-          org.apache.hadoop.mapred.SequenceFileOutputFormat.class.getName())); 
-    t.setPartitionKeys(new ArrayList<FieldSchema>());
-    t.setDatabase(MetaStoreUtils.DEFAULT_DATABASE_NAME);
-    String part_cols_str = schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.META_TABLE_PARTITION_COLUMNS);
-    if (part_cols_str != null && (part_cols_str.trim().length() != 0)) {
-      String [] part_keys = part_cols_str.trim().split("/");
-      for (String key: part_keys) {
-        FieldSchema part = new FieldSchema();
-        part.setName(key);
-        part.setType(Constants.STRING_TYPE_NAME); // default partition key
-        t.getPartitionKeys().add(part);
-      }
-    }
-    t.getSd().setNumBuckets(Integer.parseInt(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.BUCKET_COUNT, "-1")));
-    String bucketFieldName = schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.BUCKET_FIELD_NAME);
-    if ((bucketFieldName != null) && (bucketFieldName.trim().length() != 0)) {
-      t.getSd().setBucketCols(new ArrayList<String>(1));
-      t.getSd().getBucketCols().add(bucketFieldName);
-    }
-    
-    t.getSd().setSerdeInfo(new SerDeInfo());
-    t.getSd().getSerdeInfo().setName(t.getTableName());
-    t.getSd().getSerdeInfo().setSerializationClass(schema.getProperty(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_CLASS)); 
-    t.getSd().getSerdeInfo().setSerializationFormat(schema.getProperty(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT)); 
-    t.getSd().getSerdeInfo().setSerializationLib(schema.getProperty(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_LIB));
-    if(t.getSd().getSerdeInfo().getSerializationClass() == null || (t.getSd().getSerdeInfo().getSerializationClass().length() == 0)) {
-      t.getSd().getSerdeInfo().setSerializationClass(schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.META_TABLE_SERDE));
-    }
-    
-    // hack hack TODO:pc need to create a type and then associate the type name 
-    String colstr = schema.getProperty(org.apache.hadoop.hive.metastore.api.Constants.META_TABLE_COLUMNS);
-    List<FieldSchema>  fields = new ArrayList<FieldSchema>();
-    t.getSd().setCols(fields);
-    if(colstr != null) {
-      String[] cols =  colstr.split(",");
-      for (String colName : cols) {
-        FieldSchema col = new FieldSchema(colName, Constants.STRING_TYPE_NAME, "default string type");
-        fields.add(col);
-      }
-    } 
-    
-    if(fields.size() == 0) {
-      fields.add(new FieldSchema("__SERDE__", t.getSd().getSerdeInfo().getSerializationLib(), ""));
-    }
-    
-    // finally create table
-    try {
-      this.createTable(t);
-    } catch (Exception e) {
-      MetaStoreUtils.logAndThrowMetaException(e);
-    }
-  }
-
   public List<String> getTables(String dbname, String tablePattern) throws MetaException {
     try {
       return client.get_tables(dbname, tablePattern);
@@ -543,4 +471,11 @@
     return getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tableName);
   }
 
+  @Override
+  public List<String> listPartitionNames(String dbName, String tblName, short max)
+      throws MetaException, TException {
+    // TODO Auto-generated method stub
+    return client.get_partition_names(dbName, tblName, max);
+  }
+
 }

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java Fri Sep 19 16:56:30 2008
@@ -87,9 +87,11 @@
    * @throws TException
    * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#list_partitions(java.lang.String, java.lang.String, short)
    */
-  public List<Partition> listPartitions(String tbl_name, String db_name, short max_parts)
+  public List<Partition> listPartitions(String db_name, String tbl_name, short max_parts)
       throws NoSuchObjectException, MetaException, TException;
 
+  public List<String> listPartitionNames(String db_name, String tbl_name, short max_parts)
+    throws  MetaException, TException;
   /**
    * @param tbl
    * @return

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreClient.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreClient.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreClient.java Fri Sep 19 16:56:30 2008
@@ -319,7 +319,7 @@
 
   public Table getTable(String tableName) throws MetaException, TException, NoSuchObjectException {
     Properties schema = this.getSchema(tableName);
-    return MetaStoreUtils.getTable(schema);
+    return MetaStoreUtils.getTable(conf, schema);
   }
 
   //These will disappear when the server is unified for both filestore and dbstore
@@ -392,7 +392,7 @@
   private Partition getPartitionObject(String dbName, String tableName, List<String> partVals)
       throws MetaException, TException, NoSuchObjectException {
     Properties schema = this.getSchema(tableName);
-    Table tbl = MetaStoreUtils.getTable(schema);
+    Table tbl = MetaStoreUtils.getTable(conf, schema);
     List<FieldSchema> partKeys = tbl.getPartitionKeys();
     if(partKeys.size() != partVals.size()) {
       throw new MetaException("Invalid partition key values: " + partVals);
@@ -407,7 +407,7 @@
     Path partPath = wh.getPartitionPath(dbName, tableName, pm);
     Partition tPartition = new Partition();
     tPartition.setValues(partVals);
-    tPartition.setSd(tbl.getSd());
+    tPartition.setSd(tbl.getSd()); // TODO: get a copy
     tPartition.setParameters(new HashMap<String, String>());
     tPartition.getSd().setLocation(partPath.toString());
     return tPartition;
@@ -432,4 +432,11 @@
     return false;
   }
 
+  @Override
+  public List<String> listPartitionNames(String db_name, String tbl_name, short max_parts)
+      throws MetaException, TException {
+    // TODO Auto-generated method stub
+    return new ArrayList<String>();
+  }
+
 }

Modified: hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreServer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreServer.java?rev=697291&r1=697290&r2=697291&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreServer.java (original)
+++ hadoop/core/trunk/src/contrib/hive/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreServer.java Fri Sep 19 16:56:30 2008
@@ -27,8 +27,6 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -40,9 +38,12 @@
 import org.apache.hadoop.hive.metastore.api.ThriftMetaStore;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
 import org.apache.hadoop.hive.metastore.api.UnknownTableException;
-import org.apache.hadoop.hive.serde.SerDe;
-import org.apache.hadoop.hive.serde.SerDeException;
-import org.apache.hadoop.hive.serde.SerDeField;
+import org.apache.hadoop.hive.serde2.Deserializer;
+import org.apache.hadoop.hive.serde2.SerDeException;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.StructField;
+import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
 import org.apache.hadoop.util.StringUtils;
 
 import com.facebook.fb303.FacebookBase;
@@ -298,66 +299,12 @@
     }
 
 
-    /**
-     * normalizeType
-     *
-     * For pretty printing
-     *
-     * @param type a type name
-     * @return cleaned up - remove Java.lang and make numbers into int , ...
-     */
-    public String normalizeType(String type) {
-      Pattern tpat = Pattern.compile("java.lang.");
-      Matcher m = tpat.matcher(type);
-      type = m.replaceFirst("");
-      String ret = type;
-      if(type.equals("String")) {
-        ret = "string";
-      }  else if(type.equals("Integer")) {
-        ret = "int";
-      }
-      return ret;
-
-    }
-
-
-    /**
-     * hfToStrting
-     *
-     * Converts a basic SerDe's type to a string. It doesn't do any recursion.
-     *
-     * @param f the hive field - cannot be null!
-     * @return a string representation of the field's type
-     * @exception MetaException - if the SerDe raises it or the field is null
-     *
-     */
-    private String hfToString(SerDeField f) throws MetaException {
-      String ret;
-
-      try {
-        if(f.isPrimitive()) {
-          ret = this.normalizeType(f.getType().getName());
-        } else if(f.isList()) {
-          ret = "List<" +  this.normalizeType(f.getListElementType().getName()) + ">";
-        } else if(f.isMap()) {
-          ret = "Map<" + this.normalizeType(f.getMapKeyType().getName()) + "," +
-            this.normalizeType(f.getMapValueType().getName()) + ">";
-        } else {
-          // complex type and we just show the type name of the complex type
-          ret = f.getName();
-        }
-      }  catch(Exception e) {
-        StringUtils.stringifyException(e);
-        throw new MetaException(e.getMessage());
-      }
-      return ret;
-    }
     public ArrayList<FieldSchema> get_fields(String db, String table_name) throws MetaException,UnknownTableException, UnknownDBException {
 
       ArrayList<FieldSchema> str_fields = new ArrayList<FieldSchema>();
       String [] names = table_name.split("\\.");
       String base_table_name = names[0];
-      List<SerDeField> hive_fields = new ArrayList<SerDeField>();
+      String last_name = names[names.length-1];
 
       AbstractMap<String,String> schema_map = get_schema(base_table_name); // will throw UnknownTableException if not found
       Properties p = new Properties();
@@ -367,40 +314,41 @@
       }
       // xxx
 
-      SerDeField hf = null;
-
       try {
         //            Table t = Table.readTable(p, this.db);
-        SerDe s = MetaStoreUtils.getSerDe( conf_, p);
-
+        Deserializer s = MetaStoreUtils.getDeserializer( conf_, p);
+        ObjectInspector oi = s.getObjectInspector();
+        
         // recurse down the type.subtype.subsubtype expression until at the desired type
         for(int i =  1; i < names.length; i++) {
-          hf = s.getFieldFromExpression(hf,names[i]);
+          if (!(oi instanceof StructObjectInspector)) {
+            oi = s.getObjectInspector();
+            break;
+          }
+          StructObjectInspector soi = (StructObjectInspector)oi;
+          StructField sf = soi.getStructFieldRef(names[i]);
+          if (sf == null) {
+            // If invalid field, then return the schema of the table
+            oi = s.getObjectInspector();
+            break;
+          } else {
+            oi = sf.getFieldObjectInspector();
+          }
         }
 
         // rules on how to recurse the SerDe based on its type
-        if(hf != null && hf.isPrimitive()) {
-          hive_fields.add(hf);
-        } else if(hf != null && hf.isList()) {
-          // don't remember why added this rule??
-          // should just be a hive_fields.add(hf)
-          try {
-            hive_fields = s.getFields(hf);
-          } catch(Exception e) {
-            hive_fields.add(hf);
-          }
-        } else if(hf != null && hf.isMap()) {
-          hive_fields.add(hf);
+        if (oi.getCategory() != Category.STRUCT) {
+          str_fields.add(new FieldSchema(last_name, oi.getTypeName(), "automatically generated"));
         } else {
-          hive_fields = s.getFields(hf);
-        }
-
-        for(SerDeField field: hive_fields) {
-          String name = field.getName();
-          String schema = this.hfToString(field);
-          str_fields.add(new FieldSchema(name, schema, "automatically generated"));
+          List<? extends StructField> fields = ((StructObjectInspector)oi).getAllStructFieldRefs();
+          for(int i=0; i<fields.size(); i++) {
+            String fieldName = fields.get(i).getFieldName();
+            String fieldTypeName = fields.get(i).getFieldObjectInspector().getTypeName();
+            str_fields.add(new FieldSchema(fieldName, fieldTypeName, "automatically generated"));
+          }
         }
         return str_fields;
+
       } catch(SerDeException e) {
         StringUtils.stringifyException(e);
         MetaException m = new MetaException();



Mime
View raw message