Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB6B510B9C for ; Mon, 24 Feb 2014 17:52:41 +0000 (UTC) Received: (qmail 20362 invoked by uid 500); 24 Feb 2014 17:52:21 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 20332 invoked by uid 500); 24 Feb 2014 17:52:20 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 20309 invoked by uid 99); 24 Feb 2014 17:52:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Feb 2014 17:52:19 +0000 X-ASF-Spam-Status: No, hits=-0.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of 0x6e6562@gmail.com designates 209.85.128.172 as permitted sender) Received: from [209.85.128.172] (HELO mail-ve0-f172.google.com) (209.85.128.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Feb 2014 17:52:15 +0000 Received: by mail-ve0-f172.google.com with SMTP id jz11so4325760veb.3 for ; Mon, 24 Feb 2014 09:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QZ0phUP6t0tKQC9DSBUZX6D7MLgJRustqTSWELcM4KY=; b=bcwOUykgPIuU7AP6kURfGNQ4mHYTBGsb8d42CQa8TMw8UUKwJMO4hLmAIG0aYaHDIM Rmi8lO+X3XfaO6ueO9hlfbVtdADci1wno8w/5ema/hbmxo+T4vi9b+DDtUi275C/dZSY qBmxLxHCvETPgv10pr+dTYoI9MZ0lz7UGE9ztAYy3tmqIbc51svDxAnSjWdPrrMivoVa fB+FN8ZRdnbdNwmER49JJdUtuaoXZPbrqiZeO0hMDsm5i5xDZ/1Y16L/r9k9d8jkP2MK jlhORdMVz4Qiy+ILjy7o2k0S3BbSI1zEDQYETXoLFYQrqSs+cLi112n0AEnBclqhRtoZ wPSw== MIME-Version: 1.0 X-Received: by 10.52.191.9 with SMTP id gu9mr11380583vdc.37.1393264314269; Mon, 24 Feb 2014 09:51:54 -0800 (PST) Received: by 10.58.109.33 with HTTP; Mon, 24 Feb 2014 09:51:54 -0800 (PST) In-Reply-To: References: Date: Mon, 24 Feb 2014 17:51:54 +0000 Message-ID: Subject: Re: CQL decimal encoding From: Ben Hood <0x6e6562@gmail.com> To: user@cassandra.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hey Peter, On Mon, Feb 24, 2014 at 5:25 PM, Peter Lin wrote: > > Not sure what you mean by the question. > > Are you talking about the structure of BigDecimal in java? If that is your > question, the java's BigDecimal uses the first 4 bytes for scale and > remaining bytes for BigInteger I'm talking about the encoding of an arbitrary precision value in a platform neutral fashion such that interoperability between different language bindings is assured. Say you have an Java app writing to Cassandra and a Python app reading this data back out - ideally all language bindings would pack and unpack the data in an interoperable fashion. Also, I'm not sure what restrictions the server imposes on the encoding of the decimal type - can you for example just write any old (unchecked) bogus data into a decimal column via CQL? My situation is that I'm implementing the marshalling for the gocql driver, which is a generic CQL driver for Go. So ideally I'd like to provide an implementation that is generic across all applications. I'm using the class big.Rat from the Go standard library, which provides a similar interface to BigDecimal in Java and decimal.Decimal in Python. It has it's own encoding/decoding functions, but this format is specific to Go binary encoding and hence is not portable. So I have taken cue from 4 byte scale/variable length numerator strategy used by the Java BigDecimal and I've got something going using that: https://github.com/gocql/gocql/pull/120 I guess I was looking for some kind of spec for the on-wire format of the decimal type. Or in the absence of a spec, just a heads up from other language driver implementors as to what approach they've taken. Does this make sense? Cheers, Ben