Permalink
Browse files

Merge branch 'master' into index-slots

  • Loading branch information...
2 parents 605728f + 6593374 commit 7ed34f81d10fef52d9c5966165fe84c786df5a63 Oleg Andreev committed May 25, 2008
Showing with 21 additions and 18 deletions.
  1. +4 −15 lib/strokedb/document.rb
  2. +1 −1 lib/strokedb/views/view_storage.rb
  3. +16 −2 lib/strokedb/volumes/skiplist_volume.rb
View
19 lib/strokedb/document.rb
@@ -111,7 +111,7 @@ def delete(meta)
case meta
when Document
_delete meta
- _module = StrokeDB::Document.collect_meta_modules(@document.store, meta).first
+ _module = MetaModulesCollector.new(@document.store, meta).collect!.first
when Meta
_delete meta.document(@document.store)
_module = meta
@@ -135,7 +135,7 @@ def add_meta(meta, opts = {})
case meta
when Document
push meta
- _module = StrokeDB::Document.collect_meta_modules(@document.store, meta).first
+ _module = MetaModulesCollector.new(@document.store, meta).collect!.first
when Meta
push meta.document(@document.store)
_module = meta
@@ -343,7 +343,7 @@ def to_optimized_raw #:nodoc:
def self.from_raw(store, raw_slots, opts = {}, &block) #:nodoc:
doc = new(store, raw_slots, true, &block)
- collect_meta_modules(store, raw_slots[Meta.meta_uuid]).each do |meta_module|
+ MetaModulesCollector.new(store, raw_slots[Meta.meta_uuid]).collect!.each do |meta_module|
unless doc.is_a? meta_module
doc.extend(meta_module)
end
@@ -716,7 +716,7 @@ def collect!
meta_names << @subject[:name]
end
- meta_names
+ meta_names.map { |m| m.is_a?(String) ? (m.constantize rescue nil) : m }.compact
end
def lookup_version_for_meta(meta)
@@ -740,17 +740,6 @@ def has_meta_definition?(mod, metadoc)
end
end
-
-
- # returns an array of meta modules (as constants) for a given something
- # (a document reference, a document itself, or an array of the former)
- def self.collect_meta_modules(store, meta) #:nodoc:
- @collector = MetaModulesCollector.new(store, meta)
- meta_names = @collector.collect!
-
- meta_names.map { |m| m.is_a?(String) ? (m.constantize rescue nil) : m }.compact
- end
-
def generate_new_version!
self.version = Util.random_uuid
end
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 7ed34f8

Please sign in to comment.