Fix delete functions for tags & partition.
This commit is contained in:
parent
9b897ac62b
commit
eac9a77fa6
@ -203,11 +203,12 @@ class DODB::RAMOnlyPartition(V) < DODB::CachedPartition(V)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete(partition, &matcher)
|
def delete(partition, &matcher)
|
||||||
new_partition = @data[partition].select do |key|
|
if keys = @data[partition]?
|
||||||
|
new_partition = keys.select do |key|
|
||||||
item = @storage[key]
|
item = @storage[key]
|
||||||
! yield item
|
! yield item
|
||||||
end
|
end
|
||||||
|
|
||||||
@data[partition] = new_partition
|
@data[partition] = new_partition
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@ -171,6 +171,18 @@ class DODB::CachedTags(V) < DODB::Tags(V)
|
|||||||
|
|
||||||
r_value
|
r_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(tag, &matcher)
|
||||||
|
# Use `get_with_indexes` to retrieve data on-disk, if necessary.
|
||||||
|
new_tag = get_with_indexes(tag).map(&.[1]).select do |key|
|
||||||
|
item = @storage[key]
|
||||||
|
! yield item
|
||||||
|
end
|
||||||
|
|
||||||
|
@data[tag] = new_tag
|
||||||
|
|
||||||
|
super(tag, matcher)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
@ -191,7 +203,6 @@ class DODB::RAMOnlyTags(V) < DODB::CachedTags(V)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def deindex(key, value)
|
def deindex(key, value)
|
||||||
super(key, value)
|
|
||||||
indices = key_proc.call value
|
indices = key_proc.call value
|
||||||
|
|
||||||
indices.each do |tag|
|
indices.each do |tag|
|
||||||
@ -209,18 +220,20 @@ class DODB::RAMOnlyTags(V) < DODB::CachedTags(V)
|
|||||||
keys.each do |data_key|
|
keys.each do |data_key|
|
||||||
r_value << { @storage[data_key], data_key }
|
r_value << { @storage[data_key], data_key }
|
||||||
end
|
end
|
||||||
else
|
|
||||||
# Get the key from the database representation on the file-system.
|
|
||||||
tag_directory = indexing_directory tag
|
|
||||||
raise MissingEntry.new(@name, tag) unless Dir.exists? tag_directory
|
|
||||||
|
|
||||||
Dir.each_child tag_directory do |child|
|
|
||||||
r_value << { @storage[get_key child], get_key child }
|
|
||||||
end
|
|
||||||
|
|
||||||
@data[tag] = r_value.map &.[1]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
r_value
|
r_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(tag, &matcher)
|
||||||
|
# Use `get_with_indexes` to retrieve data on-disk, if necessary.
|
||||||
|
if keys = @data[tag]?
|
||||||
|
new_tag = keys.select do |key|
|
||||||
|
item = @storage[key]
|
||||||
|
! yield item
|
||||||
|
end
|
||||||
|
|
||||||
|
@data[tag] = new_tag
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user