Enable "get?" functions for partitions and tags.

paper
Philippe PITTOLI 2024-05-06 20:20:07 +02:00
parent 183432eb32
commit 0dc384dd79
2 changed files with 24 additions and 2 deletions

View File

@ -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

View File

@ -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|