Package oracle.kv.hadoop.hive.table
Class TableSerDe
- java.lang.Object
-
- org.apache.hadoop.hive.serde2.AbstractSerDe
-
- oracle.kv.hadoop.hive.table.TableSerDe
-
- All Implemented Interfaces:
Deserializer
,SerDe
,Serializer
public class TableSerDe extends AbstractSerDe
Concrete implementation of TableSerDeBase that performs deserialization and/or serialization of data loaded into a KVStore via the PrimaryKey based Table API. - Note on Logging - Two loggers are currently employed by this class:- One logger based on Log4j version 1, accessed via the org.apache.commons.logging wrapper.
- One logger based on the Log4j2 API.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Object>
hiveRow
protected MapWritable
kvMapWritable
protected static String
USER_SECURITY_DIR
-
Fields inherited from class org.apache.hadoop.hive.serde2.AbstractSerDe
configErrors
-
-
Constructor Summary
Constructors Constructor Description TableSerDe()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectInspector
createObjectInspector()
Object
deserialize(Writable field)
Deserializes the given Writable parameter and returns a Java Object representing the contents of that parameter.ObjectInspector
getObjectInspector()
Returns the ObjectInspector that can be used to navigate through the internal structure of the Object returned from the deserialize method.SerDeStats
getSerDeStats()
Returns statistics collected when deserializing and/or serializing.Class<? extends Writable>
getSerializedClass()
Return the Writable class returned by the serialize method; which is used to initialize the SequenceFile header.void
initialize(Configuration job, Properties tbl)
void
initialize(Configuration job, Properties tableProperties, Properties partitionProperties)
The original org.apache.hadoop.hive.serde2.AbstractSerDe.initialize method from Hive 1 was a 2-arg method.protected void
resetStaticFields()
For testing only.Writable
serialize(Object obj, ObjectInspector objectInspector)
Serialize the given Object by navigating inside the Object with the given ObjectInspector.protected void
setStore(KVStore testStore)
For testing only; to support the use of a mocked store.String
toString()
protected void
validateParams(Properties tbl)
Verifies that the names and types of the fields in the KV Store table correctly map to the names and types of the Hive table against which the Hive query is to be executed.-
Methods inherited from class org.apache.hadoop.hive.serde2.AbstractSerDe
getConfigurationErrors, shouldStoreFieldsInMetastore
-
-
-
-
Field Detail
-
USER_SECURITY_DIR
protected static final String USER_SECURITY_DIR
-
kvMapWritable
protected MapWritable kvMapWritable
-
-
Method Detail
-
validateParams
protected void validateParams(Properties tbl) throws SerDeException
Verifies that the names and types of the fields in the KV Store table correctly map to the names and types of the Hive table against which the Hive query is to be executed. Note that this method assumes that both the KVStore parameters and the serde parameters have been initialized. If a mismatch is found between KV Store fields and Hive columns, then a SerDeException will be thrown with a descriptive message.- Throws:
SerDeException
-
createObjectInspector
protected ObjectInspector createObjectInspector() throws SerDeException
- Throws:
SerDeException
-
deserialize
public Object deserialize(Writable field) throws SerDeException
Deserializes the given Writable parameter and returns a Java Object representing the contents of that parameter. The field parameter of this method references a field from a row of the KVStore table having the name specified by the tableName field of this class. Thus, the Object returned by this method references the contents of that table field.- Specified by:
deserialize
in interfaceDeserializer
- Parameters:
field
- The Writable object containing a serialized object from a row of the KVStore table with name specified by tableName.- Returns:
- A Java object representing the contents in the given table field parameter.
- Throws:
SerDeException
-
serialize
public Writable serialize(Object obj, ObjectInspector objectInspector) throws SerDeException
Serialize the given Object by navigating inside the Object with the given ObjectInspector. The given Object references a Hive row and the return value is an instance of Writable that references a KVStore table fieldName:fieldValue pair.- Specified by:
serialize
in interfaceSerializer
- Parameters:
obj
- The Object whose contents are examined and from which the return value is constructed.objectInspector
- The object to use to navigate the given Object's contents.- Returns:
- A Writable object representing the contents in the given Object to seriaize.
- Throws:
SerDeException
-
initialize
public void initialize(Configuration job, Properties tableProperties, Properties partitionProperties) throws SerDeException
The original org.apache.hadoop.hive.serde2.AbstractSerDe.initialize method from Hive 1 was a 2-arg method. It is still defined in Hive 2, but is deprecated. We override the new, 3-arg method defined in Hive 2. But we currently don't yet do anything with the partitionProperties.- Overrides:
initialize
in classAbstractSerDe
- Throws:
SerDeException
-
initialize
public void initialize(Configuration job, Properties tbl) throws SerDeException
- Specified by:
initialize
in interfaceDeserializer
- Specified by:
initialize
in interfaceSerializer
- Specified by:
initialize
in classAbstractSerDe
- Throws:
SerDeException
-
getSerDeStats
public SerDeStats getSerDeStats()
Returns statistics collected when deserializing and/or serializing.- Specified by:
getSerDeStats
in interfaceDeserializer
- Specified by:
getSerDeStats
in interfaceSerializer
- Specified by:
getSerDeStats
in classAbstractSerDe
-
getObjectInspector
public ObjectInspector getObjectInspector() throws SerDeException
Returns the ObjectInspector that can be used to navigate through the internal structure of the Object returned from the deserialize method.- Specified by:
getObjectInspector
in interfaceDeserializer
- Specified by:
getObjectInspector
in classAbstractSerDe
- Throws:
SerDeException
-
getSerializedClass
public Class<? extends Writable> getSerializedClass()
Return the Writable class returned by the serialize method; which is used to initialize the SequenceFile header.- Specified by:
getSerializedClass
in interfaceSerializer
- Specified by:
getSerializedClass
in classAbstractSerDe
-
setStore
protected void setStore(KVStore testStore)
For testing only; to support the use of a mocked store.
-
resetStaticFields
protected void resetStaticFields()
For testing only. Used by the TableSerDe tests to clear state between each test, so the tests don't interfere with each other.
-
-