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 6703570bce..4ad35f8188 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 static String getRawType(String hiveType) { 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 static String getRawType(String hiveType) { 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; } 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 afdc64716d..90607ed74a 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 @@ protected Object getIndexedRowIds(GenericUDF genericUdf, ExprNodeDesc leftHandNo 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); 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 1eda36451a..ff33529eef 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 @@ -95,15 +95,15 @@ public void testFloatString() { @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); } @@ -111,7 +111,7 @@ public void testBigIntBinary() { 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); @@ -123,10 +123,10 @@ public void testDecimalString() { @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); }