Repository: hive
Updated Branches:
  refs/heads/master e3203c591 -> 286d02d7e


HIVE-12443 Hive Streaming should expose encoding and serdes for testing (Alan 
Gates, reviewed by Eugene Koifman)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/286d02d7
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/286d02d7
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/286d02d7

Branch: refs/heads/master
Commit: 286d02d7e3978ee87f580c28070074650b4f1da3
Parents: e3203c5
Author: Alan Gates <[email protected]>
Authored: Thu Nov 19 13:17:49 2015 -0800
Committer: Alan Gates <[email protected]>
Committed: Thu Nov 19 13:17:49 2015 -0800

----------------------------------------------------------------------
 .../hcatalog/streaming/AbstractRecordWriter.java | 19 +++++++++++++++++--
 .../hcatalog/streaming/DelimitedInputWriter.java |  5 +++--
 .../hcatalog/streaming/StrictJsonWriter.java     | 11 +++--------
 3 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/286d02d7/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/AbstractRecordWriter.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/AbstractRecordWriter.java
 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/AbstractRecordWriter.java
index c20e04c..5c15675 100644
--- 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/AbstractRecordWriter.java
+++ 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/AbstractRecordWriter.java
@@ -48,7 +48,7 @@ import java.util.HashSet;
 import java.util.List;
 
 
-abstract class AbstractRecordWriter implements RecordWriter {
+public abstract class AbstractRecordWriter implements RecordWriter {
   static final private Logger LOG = 
LoggerFactory.getLogger(AbstractRecordWriter.class.getName());
 
   final HiveConf conf;
@@ -110,7 +110,22 @@ abstract class AbstractRecordWriter implements 
RecordWriter {
     return result;
   }
 
-  abstract SerDe getSerde() throws SerializationError;
+  /**
+   * Get the SerDe for the Objects created by {@link #encode}.  This is public 
so that test
+   * frameworks can use it.
+   * @return serde
+   * @throws SerializationError
+   */
+  public abstract SerDe getSerde() throws SerializationError;
+
+  /**
+   * Encode a record as an Object that Hive can read with the ObjectInspector 
associated with the
+   * serde returned by {@link #getSerde}.  This is public so that test 
frameworks can use it.
+   * @param record record to be deserialized
+   * @return deserialized record as an Object
+   * @throws SerializationError
+   */
+  public abstract Object encode(byte[] record) throws SerializationError;
 
   protected abstract ObjectInspector[] getBucketObjectInspectors();
   protected abstract StructObjectInspector getRecordObjectInspector();

http://git-wip-us.apache.org/repos/asf/hive/blob/286d02d7/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/DelimitedInputWriter.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/DelimitedInputWriter.java
 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/DelimitedInputWriter.java
index b4d94e3..4f1154e 100644
--- 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/DelimitedInputWriter.java
+++ 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/DelimitedInputWriter.java
@@ -243,7 +243,7 @@ public class DelimitedInputWriter extends 
AbstractRecordWriter {
   }
 
   @Override
-  SerDe getSerde() throws SerializationError {
+  public SerDe getSerde() throws SerializationError {
     return serde;
   }
 
@@ -260,7 +260,8 @@ public class DelimitedInputWriter extends 
AbstractRecordWriter {
     return bucketObjInspectors;
   }
 
-  private Object encode(byte[] record) throws SerializationError {
+  @Override
+  public Object encode(byte[] record) throws SerializationError {
     try {
       BytesWritable blob = new BytesWritable();
       blob.set(record, 0, record.length);

http://git-wip-us.apache.org/repos/asf/hive/blob/286d02d7/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/StrictJsonWriter.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/StrictJsonWriter.java
 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/StrictJsonWriter.java
index 6ab21eb..28ea7d6 100644
--- 
a/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/StrictJsonWriter.java
+++ 
b/hcatalog/streaming/src/java/org/apache/hive/hcatalog/streaming/StrictJsonWriter.java
@@ -86,7 +86,7 @@ public class StrictJsonWriter extends AbstractRecordWriter {
   }
 
   @Override
-  SerDe getSerde() throws SerializationError {
+  public SerDe getSerde() throws SerializationError {
     return serde;
   }
 
@@ -137,13 +137,8 @@ public class StrictJsonWriter extends AbstractRecordWriter 
{
     }
   }
 
-  /**
-   * Encode Utf8 encoded string bytes using JsonSerde
-   * @param utf8StrRecord
-   * @return  The encoded object
-   * @throws SerializationError
-   */
-  private Object encode(byte[] utf8StrRecord) throws SerializationError {
+  @Override
+  public Object encode(byte[] utf8StrRecord) throws SerializationError {
     try {
       Text blob = new Text(utf8StrRecord);
       return serde.deserialize(blob);

Reply via email to