Compare commits
No commits in common. "9b6c39a7d48d904fa32e72d7ab36b6a428cfddbc" and "e4f1120335d716c10858e247b0ce85e94a602322" have entirely different histories.
9b6c39a7d4
...
e4f1120335
@ -19,12 +19,11 @@ class DODB::Index(V) < DODB::Indexer(V)
|
|||||||
|
|
||||||
symlink = file_path_index index_key.to_s
|
symlink = file_path_index index_key.to_s
|
||||||
|
|
||||||
if ::File.symlink? symlink
|
# FIXME: Check it’s not pointing to “old_value”, if any, before raising.
|
||||||
# In case both old and new values are pointing to the same key,
|
if ::File.exists? symlink
|
||||||
# this is not considered a collision.
|
|
||||||
if old_value
|
if old_value
|
||||||
old_key = key_proc.call old_value
|
old_key = key_proc.call old_value
|
||||||
return if index_key == old_key
|
return if symlink == file_path_index old_key.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
raise IndexOverload.new "index '#{@name}' is overloaded for key '#{key}', file #{symlink} exists"
|
raise IndexOverload.new "index '#{@name}' is overloaded for key '#{key}', file #{symlink} exists"
|
||||||
@ -40,6 +39,11 @@ class DODB::Index(V) < DODB::Indexer(V)
|
|||||||
|
|
||||||
Dir.mkdir_p ::File.dirname symlink
|
Dir.mkdir_p ::File.dirname symlink
|
||||||
|
|
||||||
|
# FIXME: Now that this is done in check!, can we remove it?
|
||||||
|
if ::File.exists? symlink
|
||||||
|
raise Exception.new "symlink already exists: #{symlink}"
|
||||||
|
end
|
||||||
|
|
||||||
::File.symlink get_data_symlink_index(key), symlink
|
::File.symlink get_data_symlink_index(key), symlink
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -92,7 +96,9 @@ class DODB::Index(V) < DODB::Indexer(V)
|
|||||||
|
|
||||||
def get_key_on_fs(index : String) : Int32
|
def get_key_on_fs(index : String) : Int32
|
||||||
file_path = file_path_index index
|
file_path = file_path_index index
|
||||||
raise MissingEntry.new(@name, index) unless ::File.symlink? file_path
|
|
||||||
|
raise MissingEntry.new(@name, index) unless ::File.exists? file_path
|
||||||
|
|
||||||
::File.readlink(file_path).sub(/^.*\//, "").to_i
|
::File.readlink(file_path).sub(/^.*\//, "").to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -152,9 +158,8 @@ class DODB::CachedIndex(V) < DODB::Index(V)
|
|||||||
def check!(key, value, old_value)
|
def check!(key, value, old_value)
|
||||||
index_key = key_proc.call value
|
index_key = key_proc.call value
|
||||||
|
|
||||||
|
# FIXME: Check it’s not pointing to “old_value”, if any, before raising.
|
||||||
if data[index_key]?
|
if data[index_key]?
|
||||||
# In case both old and new values are pointing to the same key,
|
|
||||||
# this is not considered a collision.
|
|
||||||
if old_value
|
if old_value
|
||||||
old_key = key_proc.call old_value
|
old_key = key_proc.call old_value
|
||||||
return if index_key == old_key
|
return if index_key == old_key
|
||||||
|
@ -62,12 +62,11 @@ class DODB::Tags(V) < DODB::Indexer(V)
|
|||||||
return r_value if keys.size < 1
|
return r_value if keys.size < 1
|
||||||
|
|
||||||
first_key = keys.pop
|
first_key = keys.pop
|
||||||
r_value = get_with_indice(first_key) rescue return r_value
|
r_value = get_with_indice(first_key) rescue return [] of Tuple(V, Int32)
|
||||||
|
|
||||||
keys.each do |tag|
|
keys.each do |tag|
|
||||||
values = get_with_indice(tag) rescue return [] of Tuple(V, Int32)
|
values = get_with_indice(tag) rescue return [] of Tuple(V, Int32)
|
||||||
r_value &= values
|
r_value &= values
|
||||||
return r_value if r_value.size < 1
|
|
||||||
end
|
end
|
||||||
r_value
|
r_value
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user