Skip to content
Browse files

added SkiplistVolume#delete

  • Loading branch information...
1 parent 70bd2f5 commit 18123bc0669eb4ea71a5627f6c9ed4b395aad07f Oleg Andreev committed May 25, 2008
Showing with 17 additions and 3 deletions.
  1. +1 −1 lib/strokedb/views/view_storage.rb
  2. +16 −2 lib/strokedb/volumes/skiplist_volume.rb
View
2 lib/strokedb/views/view_storage.rb
@@ -26,7 +26,7 @@ def find(start_key, end_key, limit, offset, reverse, with_keys)
def replace(old_pairs, new_pairs)
old_pairs.each do |pair|
key, value = pair
- @list.insert(key,nil) if @list.find(key)
+ @list.delete(key) if @list.find(key)
end
insert(new_pairs)
end
View
18 lib/strokedb/volumes/skiplist_volume.rb
@@ -129,6 +129,16 @@ def insert(key, value, __level = nil)
crash!(e)
raise
end
+
+ def delete(key)
+ write_log(key, 0, 0)
+ @list.delete(key)
+ dump! if @log_bytes > @max_log_size
+ self
+ rescue => e
+ crash!(e)
+ raise
+ end
# Volume operations
@@ -216,8 +226,12 @@ def replay_log!(log_path, list)
checksum_invalid(msg, msg_chk[msg_length, checksum_length]) and raise LogFormatError, "WAL message checksum failure!"
key, value, level = Marshal.load(msg)
-
- list.insert(key, value, level)
+
+ if level == 0
+ list.delete(key)
+ else
+ list.insert(key, value, level)
+ end
end
end

0 comments on commit 18123bc

Please sign in to comment.
Something went wrong with that request. Please try again.