We’re working on an Android Mobile application using Couchbase Mobile and have hit a problem when using ‘shadow buckets’ for mobile synchronisation. I was wondering if anyone else had encountered the problem, if it was a known issue - any information at all on this would be very useful. The problem is as follows:
When an attribute with a large ‘long’ value (a little more precisely: an integer value of size greater than {say} a Java int primitive, i.e. > 2^31-1) is specified in a document, then Couchbase stores this field without using scientific notation in the application bucket. We have ascertained this by examining the operating system files used by Couchbase. However, when a document containing a ‘long’ is copied from the application bucket to a corresponding shadow bucket, then the ‘long’ will be stored using scientific notation. Again, we have ascertained this by examining the files used by Couchbase.
As an example of the problem: if I were to store the current Unix epoch time (1425295827909) in an attribute called ‘t_now’ in a Couchbase document, then the attribute will be stored as:
“t_now” : 1425295827909
in the application bucket but as:
“t_now” : 1.425295827909e12
In the shadow bucket.
Note that this problem is not apparent when viewing documents in the Couchbase server admin console, as conversion from scientific notation to ‘plain’ (non-scientific) format appears to take place here.
This unexpected conversion to scientific notation is causing a range of problems for us. In particular, when we create a doc with a ‘long’ at Couchbase server, this ‘long’ will be converted to scientific notation on copying to the shadow bucket. This value will then be synced over to all mobile devices and then, at some stage, back to the server. The nett result of all this is that, eventually, any ‘long’ in ‘plain’ (non-scientific) notation at the server will be overwritten with the same value expressed using scientific notation.
IMO this is a bug as it seems to me that attribute values stored in a document in a shadow bucket should be exactly the same (in terms of value and representation) as the corresponding values stored in the document in the application bucket.