More consistent API.
This commit is contained in:
parent
8a96c3302c
commit
cf57773a25
@ -43,11 +43,10 @@ class DODB::Partition(V) < DODB::Indexer(V)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get(partition) : Array(V)
|
def get(partition) : Array(V)
|
||||||
r_value = Array(V).new
|
|
||||||
|
|
||||||
partition_directory = indexing_directory partition
|
partition_directory = indexing_directory partition
|
||||||
|
raise MissingEntry.new(@name, partition) unless Dir.exists? partition_directory
|
||||||
|
|
||||||
return r_value unless Dir.exists? partition_directory
|
r_value = Array(V).new
|
||||||
|
|
||||||
Dir.each_child partition_directory do |child|
|
Dir.each_child partition_directory do |child|
|
||||||
r_value << @storage[get_key child]
|
r_value << @storage[get_key child]
|
||||||
|
@ -42,11 +42,10 @@ class DODB::Tags(V) < DODB::Indexer(V)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_with_indice(tag : String) : Array(Tuple(V, Int32))
|
def get_with_indice(tag : String) : Array(Tuple(V, Int32))
|
||||||
r_value = Array(Tuple(V, Int32)).new
|
|
||||||
|
|
||||||
tag_directory = indexing_directory tag
|
tag_directory = indexing_directory tag
|
||||||
|
raise MissingEntry.new(@name, tag) unless Dir.exists? tag_directory
|
||||||
|
|
||||||
return r_value unless Dir.exists? tag_directory
|
r_value = Array(Tuple(V, Int32)).new
|
||||||
|
|
||||||
Dir.each_child tag_directory do |child|
|
Dir.each_child tag_directory do |child|
|
||||||
key = get_key child
|
key = get_key child
|
||||||
@ -56,10 +55,18 @@ class DODB::Tags(V) < DODB::Indexer(V)
|
|||||||
r_value
|
r_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# `get_with_indices` gets values with all the tags.
|
||||||
|
|
||||||
def get_with_indices(keys : Array(String)) : Array(Tuple(V, Int32))
|
def get_with_indices(keys : Array(String)) : Array(Tuple(V, Int32))
|
||||||
r_value = Array(Tuple(V, Int32)).new
|
r_value = Array(Tuple(V, Int32)).new
|
||||||
|
return r_value if keys.size < 1
|
||||||
|
|
||||||
|
first_key = keys.pop
|
||||||
|
r_value = get_with_indice(first_key) rescue return [] of Tuple(V, Int32)
|
||||||
|
|
||||||
keys.each do |tag|
|
keys.each do |tag|
|
||||||
r_value.concat get_with_indice tag
|
values = get_with_indice(tag) rescue return [] of Tuple(V, Int32)
|
||||||
|
r_value &= values
|
||||||
end
|
end
|
||||||
r_value
|
r_value
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user