Skip to content

BigDecimal is incorrect #83

Closed
woolfel opened this Issue Nov 3, 2012 · 2 comments

2 participants

@woolfel
woolfel commented Nov 3, 2012

The way cassandra stores and uses BigDecimal is reverse from what you have. The first 4 bytes is the scale and the remaining bytes are the BigInteger.

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cassandra/cassandra-all/1.0.0-rc2/org/apache/cassandra/cql/jdbc/JdbcDecimal.java

Even though this will store properly for .Net, the minute someone tries to use cassandra-cli or cqlsh, it will result in java heap space error and crash. If people are reading data from other platforms like java or python, it will be wrong.

@nberardi
nberardi commented Nov 5, 2012

Please review the byte output to make sure that they are in the proper order and the sections are facing the right way for their endianess.

private readonly BigDecimal bigDecimal = 100002334.4563D;
private readonly byte[] dotNetByteOrder = new byte[] { 179, 69, 9, 214, 232, 0, 4, 0, 0, 0 };
private readonly byte[] javaByteOrder = new byte[] { 0, 0, 0, 4, 0, 232, 214, 9, 69, 179 };

This is taken from the following test, please update the test with the correct values if the assumptions are wrong.

d05b40e#diff-6

@nberardi nberardi was assigned Nov 5, 2012
@nberardi

Closing since there hasn't been any response.

@nberardi nberardi closed this Nov 13, 2012
@achinn achinn pushed a commit to achinn/fluentcassandra that referenced this issue Sep 12, 2014
Alex Chinn Fixed regression caused by fix to issue #83. If a null value is found…
… in a decimal type column then you'll get a NullReferenceException when reading it out.
65ea4b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.