liuis / leveldb

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

Feature Request - Count(start, limit) and Delete(start, limit) #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Count(start, limit)

seems that some people also want a count/size method without calling the 
iterator to loop thru the entire set just to count the number of records.  So, 
would be great if there is a method like "Count(start, limit)"  or 
"Count(range)"  to count the number of records which fall inside the range 
[start, limit).

Delete(start, limit)

A fast Delete methods which delete a range of keys [start, limit) would be 
nice.   I guess this can be optimized inside levelDB to do this instead of 
having my program looping and delete one by one. 

Original issue reported on code.google.com by saw...@gmail.com on 4 Sep 2012 at 10:18

GoogleCodeExporter commented 9 years ago
Similarly, it'd be great if we could get the size of an entry, without also 
fetching the value from disk.

Original comment by alexkarp...@gmail.com on 15 Sep 2012 at 11:35

GoogleCodeExporter commented 9 years ago
There is no way to implement Count more efficiently inside leveldb than outside.

"Delete range" could theoretically be implemented more efficiently inside 
leveldb, but it would be very complicated or would interact badly with 
snapshots.  So it won't happen any time soon.

Original comment by san...@google.com on 18 Sep 2012 at 5:18

GoogleCodeExporter commented 9 years ago
If a fast count is important, you can keep track of the count as you write 
entries, and write it out as it's own special entry.

# pseudo 
if (!get(k)) {
   put(k,v)
   c=get("*cnt");
   ++c;
   put("*cnt",v)
} else {
   put(k,v)
}

Original comment by earone...@gmail.com on 10 Jul 2014 at 6:44