You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2017/05/03 20:42:14 UTC

hive git commit: HIVE-15795 : Support Accumulo Index Tables in Hive Accumulo Connector (Mike Fagan, reviewed by Josh Elser) ADDENDUM

Repository: hive
Updated Branches:
  refs/heads/master 5d459665b -> ed6501ed3


 HIVE-15795 : Support Accumulo Index Tables in Hive Accumulo Connector (Mike Fagan, reviewed by Josh Elser) ADDENDUM


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

Branch: refs/heads/master
Commit: ed6501ed39040f308c792f22756d3169f37cb3a4
Parents: 5d45966
Author: sergey <se...@apache.org>
Authored: Wed May 3 13:42:02 2017 -0700
Committer: sergey <se...@apache.org>
Committed: Wed May 3 13:42:02 2017 -0700

----------------------------------------------------------------------
 .../hive/accumulo/AccumuloIndexLexicoder.java       |  8 ++++----
 .../accumulo/predicate/AccumuloRangeGenerator.java  |  2 +-
 .../hive/accumulo/TestAccumuloIndexLexicoder.java   | 16 ++++++++--------
 3 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/ed6501ed/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java
----------------------------------------------------------------------
diff --git a/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java b/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java
index 6703570..4ad35f8 100644
--- a/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java
+++ b/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java
@@ -73,9 +73,9 @@ public final class AccumuloIndexLexicoder {
       case serdeConstants.DOUBLE_TYPE_NAME :
         return DOUBLE_LEXICODER.encode(Double.valueOf(new String(value)));
       case serdeConstants.BIGINT_TYPE_NAME :
-        return LONG_LEXICODER.encode(Long.valueOf(new String(value)));
-      case serdeConstants.DECIMAL_TYPE_NAME :
         return BIG_INTEGER_LEXICODER.encode(new BigInteger(new String(value), 10));
+      case serdeConstants.DECIMAL_TYPE_NAME :
+        return new String(value).getBytes(UTF_8);
       default :
         // return the passed in string value
         return value;
@@ -99,9 +99,9 @@ public final class AccumuloIndexLexicoder {
       case serdeConstants.DOUBLE_TYPE_NAME :
         return DOUBLE_LEXICODER.encode(ByteBuffer.wrap(value).asDoubleBuffer().get());
       case serdeConstants.BIGINT_TYPE_NAME :
-        return LONG_LEXICODER.encode(ByteBuffer.wrap(value).asLongBuffer().get());
-      case serdeConstants.DECIMAL_TYPE_NAME :
         return BIG_INTEGER_LEXICODER.encode(new BigInteger(value));
+      case serdeConstants.DECIMAL_TYPE_NAME :
+        return new String(value).getBytes(UTF_8);
       default :
         return value;
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/ed6501ed/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java
----------------------------------------------------------------------
diff --git a/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java b/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java
index afdc647..90607ed 100644
--- a/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java
+++ b/accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java
@@ -347,7 +347,7 @@ public class AccumuloRangeGenerator implements NodeProcessor {
       throws SemanticException {
     Text constText = getConstantText(objInspector);
     byte[] value = constText.toString().getBytes(UTF_8);
-    byte[] encoded = AccumuloIndexLexicoder.encodeValue(value, objInspector.getTypeName(), true);
+    byte[] encoded = AccumuloIndexLexicoder.encodeValue(value, leftHandNode.getTypeString(), true);
     Range range = getRange(genericUdf, leftHandNode, new Text(encoded));
     if (indexScanner != null) {
       return indexScanner.getIndexRowRanges(columnName, range);

http://git-wip-us.apache.org/repos/asf/hive/blob/ed6501ed/accumulo-handler/src/test/org/apache/hadoop/hive/accumulo/TestAccumuloIndexLexicoder.java
----------------------------------------------------------------------
diff --git a/accumulo-handler/src/test/org/apache/hadoop/hive/accumulo/TestAccumuloIndexLexicoder.java b/accumulo-handler/src/test/org/apache/hadoop/hive/accumulo/TestAccumuloIndexLexicoder.java
index 70362ff..b19f10e 100644
--- a/accumulo-handler/src/test/org/apache/hadoop/hive/accumulo/TestAccumuloIndexLexicoder.java
+++ b/accumulo-handler/src/test/org/apache/hadoop/hive/accumulo/TestAccumuloIndexLexicoder.java
@@ -112,15 +112,15 @@ public class TestAccumuloIndexLexicoder {
 
   @Test
   public void testBigIntBinary() {
-    byte[] value = ByteBuffer.allocate(8).putLong(1232322323).array();
-    byte[] encoded = new LongLexicoder().encode(1232322323L);
+    byte[] value = new String("1232322323").getBytes(UTF_8);
+    byte[] encoded = new BigIntegerLexicoder().encode(new BigInteger("1232322323", 10));
 
-    byte[] lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.BIGINT_TYPE_NAME, false);
+    byte[] lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.BIGINT_TYPE_NAME, true);
     assertArrayEquals(lex, encoded);
 
     value = new BigInteger( "1232322323", 10 ).toByteArray();
     encoded = new BigIntegerLexicoder().encode(new BigInteger("1232322323", 10 ));
-    lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.DECIMAL_TYPE_NAME, false);
+    lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.BIGINT_TYPE_NAME, false);
     assertArrayEquals(lex, encoded);
   }
 
@@ -128,7 +128,7 @@ public class TestAccumuloIndexLexicoder {
   public void testDecimalString() {
     String strVal = "12323232233434";
     byte[] value = strVal.getBytes(UTF_8);
-    byte[] encoded = new BigIntegerLexicoder().encode(new BigInteger(strVal, 10));
+    byte[] encoded = strVal.getBytes(UTF_8);
 
     byte[] lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.DECIMAL_TYPE_NAME, true);
     assertArrayEquals(lex, encoded);
@@ -140,10 +140,10 @@ public class TestAccumuloIndexLexicoder {
 
   @Test
   public void testDecimalBinary() {
-    BigInteger value = new BigInteger("12323232233434", 10);
-    byte[] encoded = new BigIntegerLexicoder().encode(value);
+    byte[] value = new BigInteger("12323232233434", 10).toString().getBytes(UTF_8);
+    byte[] encoded = new String(value).getBytes(UTF_8);
 
-    byte[] lex = AccumuloIndexLexicoder.encodeValue(value.toByteArray(), serdeConstants.DECIMAL_TYPE_NAME, false);
+    byte[] lex = AccumuloIndexLexicoder.encodeValue(value, serdeConstants.DECIMAL_TYPE_NAME, false);
     assertArrayEquals(lex, encoded);
   }