byzhang / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Adapting sequence numbers to timestamps #248

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am considering a custom modification where sequence numbers are actually 
timestamps.  I would use this to automatically prune older records during 
compactions.  New sequence numbers would be generated like this:

cur_time=env->NowMicros();
if (cur_time<=version->LastSequence)
   ++version->LastSequence;
else
   version->LastSequence=cur_time;

return(version->LastSequence);

No, this is not the exact code … just the concept.  The "then" branch handles 
case where multiple writes happen within the resolution of the clock.  And I 
might create a NowNanos() just to reduce that too.  

I believe snapshots and such would work as is.  Then I only have to add logic 
to the block iterators to skip old stuff.

Thoughts??

Original issue reported on code.google.com by mvonmasz...@gmail.com on 13 Aug 2014 at 9:38