You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by om...@apache.org on 2015/11/20 22:46:44 UTC

[04/12] hive git commit: HIVE-12443 Hive Streaming should expose encoding and serdes for testing (Alan Gates, reviewed by Eugene Koifman)

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/6563422f
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/6563422f
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/6563422f

Branch: refs/heads/master-fixed
Commit: 6563422f912de382e7abfc7138bffd960c98c086
Parents: d3b5a3f
Author: Alan Gates <ga...@hortonworks.com>
Authored: Thu Nov 19 13:17:49 2015 -0800
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri Nov 20 13:46:22 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/6563422f/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/6563422f/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/6563422f/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);