Enable "get?" functions for partitions and tags.
parent
183432eb32
commit
0dc384dd79
|
@ -39,7 +39,7 @@ class DODB::Partition(V) < DODB::Indexer(V)
|
|||
::File.delete symlink
|
||||
end
|
||||
|
||||
def get(partition)
|
||||
def get(partition) : Array(V)
|
||||
r_value = Array(V).new
|
||||
|
||||
partition_directory = indexing_directory partition
|
||||
|
@ -53,6 +53,12 @@ class DODB::Partition(V) < DODB::Indexer(V)
|
|||
r_value
|
||||
end
|
||||
|
||||
def get?(partition) : Array(V)?
|
||||
get partition
|
||||
rescue MissingEntry
|
||||
nil
|
||||
end
|
||||
|
||||
def delete(partition)
|
||||
delete partition, do true end
|
||||
end
|
||||
|
|
|
@ -64,6 +64,12 @@ class DODB::Tags(V) < DODB::Indexer(V)
|
|||
get_with_indice(tag).map &.[0]
|
||||
end
|
||||
|
||||
def get?(tag : String) : Array(V)?
|
||||
get tag
|
||||
rescue MissingEntry
|
||||
nil
|
||||
end
|
||||
|
||||
def get(keys : Array(String)) : Array(V)
|
||||
get_with_indices(keys.sort).map &.[0]
|
||||
end
|
||||
|
@ -140,7 +146,17 @@ class DODB::CachedTags(V) < DODB::Tags(V)
|
|||
end
|
||||
end
|
||||
|
||||
def get(tag : String)
|
||||
def get_with_indice(tag : String) : Array(Tuple(V, Int32))
|
||||
r_value = Array(Tuple(V, Int32)).new
|
||||
|
||||
@data[tag].each do |data_key|
|
||||
r_value << { @storage[data_key], data_key }
|
||||
end
|
||||
|
||||
r_value
|
||||
end
|
||||
|
||||
def get(tag : String) : Array(V)
|
||||
r_value = Array(V).new
|
||||
|
||||
@data[tag].each do |data_key|
|
||||
|
|
Loading…
Reference in New Issue