From caa97449f6087174ad1970ee8058e164a35f475f Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 28 Jul 2008 01:33:49 +0000 Subject: Remove BigDecimal support until key encoding issues are resolved. --- src/main/java/com/amazon/carbonado/raw/DataDecoder.java | 3 ++- src/main/java/com/amazon/carbonado/raw/DataEncoder.java | 5 +++-- .../amazon/carbonado/raw/GenericEncodingStrategy.java | 4 ++-- src/main/java/com/amazon/carbonado/raw/KeyDecoder.java | 5 +++-- src/main/java/com/amazon/carbonado/raw/KeyEncoder.java | 17 ++++++++++------- 5 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/raw') diff --git a/src/main/java/com/amazon/carbonado/raw/DataDecoder.java b/src/main/java/com/amazon/carbonado/raw/DataDecoder.java index 407df0c..ce5b7c9 100644 --- a/src/main/java/com/amazon/carbonado/raw/DataDecoder.java +++ b/src/main/java/com/amazon/carbonado/raw/DataDecoder.java @@ -400,7 +400,7 @@ public class DataDecoder { * @return amount of bytes read from source * @throws CorruptEncodingException if source data is corrupt * @since 1.2 - */ + * / public static int decode(byte[] src, int srcOffset, BigDecimal[] valueRef) throws CorruptEncodingException { @@ -446,6 +446,7 @@ public class DataDecoder { throw new CorruptEncodingException(null, e); } } + */ /** * Decodes the given byte array. diff --git a/src/main/java/com/amazon/carbonado/raw/DataEncoder.java b/src/main/java/com/amazon/carbonado/raw/DataEncoder.java index 4b6cab4..990b7e7 100644 --- a/src/main/java/com/amazon/carbonado/raw/DataEncoder.java +++ b/src/main/java/com/amazon/carbonado/raw/DataEncoder.java @@ -362,7 +362,7 @@ public class DataEncoder { * @param dstOffset offset into destination array * @return amount of bytes written * @since 1.2 - */ + * / public static int encode(BigDecimal value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; @@ -378,13 +378,14 @@ public class DataEncoder { * @param value BigDecimal value to encode, may be null * @return amount of bytes needed to encode * @since 1.2 - */ + * / public static int calculateEncodedLength(BigDecimal value) { if (value == null) { return 1; } return signedVarIntLength(value.scale()) + calculateEncodedLength(value.unscaledValue()); } + */ /** * Encodes the given optional byte array into a variable amount of diff --git a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java index c5417c4..c68f06b 100644 --- a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java +++ b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java @@ -383,8 +383,8 @@ public class GenericEncodingStrategy { Class clazz = propertyType.toClass(); if (clazz != null) { return Lob.class.isAssignableFrom(clazz) || - BigInteger.class.isAssignableFrom(clazz) || - BigDecimal.class.isAssignableFrom(clazz); + BigInteger.class.isAssignableFrom(clazz);/* || + BigDecimal.class.isAssignableFrom(clazz);*/ } return false; } diff --git a/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java b/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java index dc838e6..eb44c53 100644 --- a/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java +++ b/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java @@ -443,7 +443,7 @@ public class KeyDecoder { * @return amount of bytes read from source * @throws CorruptEncodingException if source data is corrupt * @since 1.2 - */ + * / public static int decode(byte[] src, int srcOffset, BigDecimal[] valueRef) throws CorruptEncodingException { @@ -508,7 +508,7 @@ public class KeyDecoder { * @return amount of bytes read from source * @throws CorruptEncodingException if source data is corrupt * @since 1.2 - */ + * / public static int decodeDesc(byte[] src, int srcOffset, BigDecimal[] valueRef) throws CorruptEncodingException { @@ -563,6 +563,7 @@ public class KeyDecoder { valueRef[0] = new BigDecimal(unscaledValue, scale); return srcOffset - originalOffset; } + */ /** * Decodes the given byte array as originally encoded for ascending order. diff --git a/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java b/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java index 07fb94e..0c90499 100644 --- a/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java +++ b/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java @@ -434,7 +434,7 @@ public class KeyEncoder { * @param dstOffset offset into destination array * @return amount of bytes written * @since 1.2 - */ + * / public static int encode(BigDecimal value, byte[] dst, int dstOffset) { /* Encoding of first byte: @@ -450,7 +450,7 @@ public class KeyEncoder { 0xc0..0xfd: positive signum; positive exponent; 3e range, 0..61 0xfe: positive signum; four bytes follow for positive exponent 0xff: null high - */ + * / if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; @@ -467,6 +467,8 @@ public class KeyEncoder { int scale = value.scale(); int exponent = value.precision() - scale; + System.out.println("exponent: " + exponent); + System.out.println("unscaled: " + value.unscaledValue()); if (signum < 0) { if (exponent >= -0x3e && exponent < 0x3e) { @@ -502,7 +504,7 @@ public class KeyEncoder { 0x01..0x7f: negative scale; 7f range, -127..-1 0x80..0xfe: positive scale; 7f range, 0..126 0xff: positive scale; four bytes follow for scale - */ + * / if (signum < 0) { scale = ~scale; @@ -532,7 +534,7 @@ public class KeyEncoder { * @param dstOffset offset into destination array * @return amount of bytes written * @since 1.2 - */ + * / public static int encodeDesc(BigDecimal value, byte[] dst, int dstOffset) { /* Encoding of first byte: @@ -548,7 +550,7 @@ public class KeyEncoder { 0xc0..0xfd: negative signum; positive exponent; 3e range, 61..0 0xfe: negative signum; four bytes follow for positive exponent 0xff: null low - */ + * / if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; @@ -600,7 +602,7 @@ public class KeyEncoder { 0x01..0x7f: positive scale; 7f range, 0..126 0x80..0xfe: negative scale; 7f range, -127..-1 0xff: negative scale; four bytes follow for scale - */ + * / if (signum < 0) { scale = ~scale; @@ -625,7 +627,7 @@ public class KeyEncoder { * @param value BigDecimal value to encode, may be null * @return amount of bytes needed to encode * @since 1.2 - */ + * / public static int calculateEncodedLength(BigDecimal value) { if (value == null || value.signum() == 0) { return 1; @@ -639,6 +641,7 @@ public class KeyEncoder { return headerSize + calculateEncodedLength(value.unscaledValue()) + scaleSize; } + */ /** * Encodes the given optional unsigned byte array into a variable amount of -- cgit v1.2.3