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
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
FieldsFields inherited from class org.apache.hadoop.hive.serde2.AbstractSerDe
configErrors
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectInspector
deserialize
(Writable field) Deserializes the given Writable parameter and returns a Java Object representing the contents of that parameter.Returns the ObjectInspector that can be used to navigate through the internal structure of the Object returned from the deserialize method.Returns statistics collected when deserializing and/or serializing.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
For testing only.serialize
(Object obj, ObjectInspector objectInspector) Serialize the given Object by navigating inside the Object with the given ObjectInspector.protected void
For testing only; to support the use of a mocked store.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 Details
-
USER_SECURITY_DIR
-
hiveRow
-
kvMapWritable
-
-
Constructor Details
-
TableSerDe
public TableSerDe()
-
-
Method Details
-
validateParams
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
- Throws:
SerDeException
-
deserialize
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
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
- Specified by:
initialize
in interfaceDeserializer
- Specified by:
initialize
in interfaceSerializer
- Specified by:
initialize
in classAbstractSerDe
- Throws:
SerDeException
-
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
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
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
-
toString
-
setStore
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.
-