Hello everyone,
There are three places where it'd be extremely handy to have 64-bit
integers in JSON:
1. File sizes. We are otherwise limited to 4GB files.
2. Local revision counters. I updated the spec last night that explains
how to work around this, but it'd be better to not have to worry about it.
3. Vector Clocks. We are otherwise limited to only having 4 billion
changes per file, which could hypothetically happen if someone was
trying to sync something that changes often (like a sqlite database
[0]). I can work around this by allowing multiple vector clocks per
record, but it's really messy.
My proposal is that we allow 64-bit integers in our JSON. From what I
can tell, Javascript is the place where 64-bit integers don't work [1],
but the JSON spec doesn't restrict the length of integers. Here are
three proposals:
1. Send 64-bit integers in the JSON stream. We patch jsoncons if
necessary to support this. I like this approach because we're unlikely
to ever have a browser-based javascript implementation [2] of
clearskies, and nodejs has Int64 support via libraries.
{
"size": 15298937712826087
}
2. Send 64-bit integers as strings in the JSON stream. This only uses
two more characters, but it means that JSON implementations don't need
to be patched.
{
"size": "15298937712826087"
}
3. Hex-encode 64-bit integers. This uses less characters (although if
we implement the gzip extension it won't matter anyway).
{
"size": "0x365a4d83d056e7"
}
4. Send 64-bit integers as an array of two 32-bit integers.
{
"size": [3562061, 2211469031]
}
My vote is for #1 since I believe that's the way the industry will go,
but I don't feel very strongly about it. Any of these will work for our
purposes.
Steven
[0]: I realize that it'd not a good idea to sync a sqlite database with
any sync tool that doesn't have OS-provided snapshots, for consistency
reasons, but I'm just trying to think of a case where a file could have
more than 2^32 writes during its lifetime.
[1]: Supposedly ints work up to 2^53 in javascript, which is enough for
9 PB files.
[2]: There are 64-bit int libraries for browsers:
http://docs.closure-library.googlecode.com/git/class_goog_math_Long.html