TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

100 more of those BITFIELDs

77 pointsby fcambusabout 9 years ago

6 comments

derefrabout 9 years ago
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&#x2F;SETBYFIELD would be <i>polymorphic</i>.)<p>...thinking about this more, this is possible <i>now</i>, isn&#x27;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? :)
评论 #11183724 未加载
a1k0nabout 9 years ago
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&#x27;s interesting!)<p>[0] <a href="http:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1004.0403.pdf" rel="nofollow">http:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1004.0403.pdf</a><p>[1] <a href="http:&#x2F;&#x2F;roaringbitmap.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;roaringbitmap.org&#x2F;</a>
评论 #11183369 未加载
connor4312about 9 years ago
I&#x27;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&#x2F;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.
评论 #11183187 未加载
andrewfromxabout 9 years ago
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.
评论 #11182170 未加载
评论 #11182133 未加载
Dylan16807about 9 years ago
53 bits.. they&#x27;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?
bluedinoabout 9 years ago
Would like to see speed vs storage benchmarks. Bit twiddling must be a bit slow, no?
评论 #11183141 未加载
评论 #11191075 未加载