sounds like maybe the bytes aren't being converted to big endian before
sending the bytes to to Cassandra.

In my C# driver, this is what I do.

1. I get the bytes for the scale and unscaled value
2. I reverse both byte arrays
3. I copy the bytes to a new byte array

here is the actual C# code.

        public byte[] ToByteArray()
        {
            byte[] scale = BitConverter.GetBytes(Scale);
            byte[] unscaledValue = UnscaledValue.ToByteArray();

            Array.Reverse(scale);
            Array.Reverse(unscaledValue);

            byte[] bytes = new byte[unscaledValue.Length + scale.Length];
            Array.Copy(scale, 0, bytes, 0, scale.Length);
            Array.Copy(unscaledValue, 0, bytes, scale.Length,
unscaledValue.Length);
            return bytes;
        }


hope that helps


On Tue, Feb 25, 2014 at 10:56 AM, Ben Hood <0x6e6...@gmail.com> wrote:

> On Tue, Feb 25, 2014 at 12:50 PM, Peter Lin <wool...@gmail.com> wrote:
> >
> > if I have time this week, I'll try to make a patch for the spec. Can't
> > promise I can get to it this week, but having come across this issue with
> > FluentCassandra, I'd like to help others avoid it.
>
> So I may be running into an encoding bug with my serialization. I can
> round trip serialization to and from Cassandra successfully, but I
> seem to have a discrepancy with cqlsh for some values.
>
> For example, I've encoded 0.131 as \x00\x00\x00\x03\x83. This round
> trips successfully with the gocql driver, but cqlsh renders it as
> "-0.125". If I try to read the column, my driver gets the value 0.131
> back.
>
> So how do I start to debug the data that cqlsh is processing?
>
> Cheers,
>
> Ben
>

Reply via email to