With the #N syntax, Redis is getting dangerously close to having C-struct-typed fields (i.e. product types with a known bit-level encoding.)<p>I could imagine a STRUCT LOAD command (like SCRIPT LOAD) to push a struct definition to the server; and then STRUCT GETFIELD and STRUCT SETFIELD commands to manipulate the structs. The GETFIELD and SETFIELD commands would just boil down to the same BITFIELD command after dereferencing. (Heck, Redis could probably cheaply tag the fields with their struct definition, and then you could GET/SETBYFIELD would be <i>polymorphic</i>.)<p>...thinking about this more, this is possible <i>now</i>, isn't it? The struct-definition loader command, and the dereferencing commands, can all just be Lua functions passed to EVAL. The struct definitions could be loaded into a sorted set; the dereferencing commands would read from that set and then translate your query into a call to this BITFIELD command to do the work.<p>Anyone care to implement this silliness? :)
Check out Concise [0] or Roaring Bitmaps [1] before rolling your own compressed bitset scheme. Wish I had known about these sooner.<p>(I realize now this is offtopic, as this is bit fields not bit sets; nevermind, but still it's interesting!)<p>[0] <a href="http://arxiv.org/pdf/1004.0403.pdf" rel="nofollow">http://arxiv.org/pdf/1004.0403.pdf</a><p>[1] <a href="http://roaringbitmap.org/" rel="nofollow">http://roaringbitmap.org/</a>
I'm quite excited for bitfields in Redis. We are going to need to implement some bloom filter-based data structures for one of our products in the near future. Previously the best way to do this was to either keep a hash map or a binary k/v, both of which have substantial drawbacks (such as the need for locking). These bitfields, however, are a perfectly-timed ideal solution to the problem.
i love using 64 bit unsigned ints in mysql for 64 boolean columns. I do:<p>alter table foo add column bar bigint(20) unsigned default 18446744073709551615<p>and that gets you 64 111111111111111111111111111111 etc.
53 bits.. they're returning a bitfield as a double float at some layer?<p>Or am I misreading the implication and they can do signed 64 bits but not unsigned?