API change: get_with_index -> get_with_keys
This commit is contained in:
parent
378f8c76db
commit
0549879140
@ -295,7 +295,7 @@ describe "DODB::DataBase" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Removing the “flagship” tag, brace for impact.
|
# Removing the “flagship” tag, brace for impact.
|
||||||
flagship, index = db_ships_by_tags.get_with_indice("flagship")[0]
|
flagship, index = db_ships_by_tags.get_with_keys("flagship")[0]
|
||||||
flagship.tags = [] of String
|
flagship.tags = [] of String
|
||||||
db[index] = flagship
|
db[index] = flagship
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ describe "DODB::CachedDataBase" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Removing the “flagship” tag, brace for impact.
|
# Removing the “flagship” tag, brace for impact.
|
||||||
flagship, index = db_ships_by_tags.get_with_indice("flagship")[0]
|
flagship, index = db_ships_by_tags.get_with_keys("flagship")[0]
|
||||||
flagship = flagship.clone
|
flagship = flagship.clone
|
||||||
flagship.tags = [] of String
|
flagship.tags = [] of String
|
||||||
db[index] = flagship
|
db[index] = flagship
|
||||||
|
@ -256,14 +256,14 @@ class DODB::CachedPartition(V) < DODB::Partition(V)
|
|||||||
#
|
#
|
||||||
# ```
|
# ```
|
||||||
# # For example, get all red cars.
|
# # For example, get all red cars.
|
||||||
# cars_by_color.get_with_indexes "red"
|
# cars_by_color.get_with_keys "red"
|
||||||
# # Will return something like:
|
# # Will return something like:
|
||||||
# # [ (@storage[42], 42)
|
# # [ (@storage[42], 42)
|
||||||
# # , (@storage[91], 91)
|
# # , (@storage[91], 91)
|
||||||
# # ]
|
# # ]
|
||||||
# # Each tuple is composed of a car and its key in the database.
|
# # Each tuple is composed of a car and its key in the database.
|
||||||
# ```
|
# ```
|
||||||
def get_with_indexes(partition : String) : Array(Tuple(V, Int32))
|
def get_with_keys(partition : String) : Array(Tuple(V, Int32))
|
||||||
r_value = Array(Tuple(V, Int32)).new
|
r_value = Array(Tuple(V, Int32)).new
|
||||||
|
|
||||||
# In case the partition is cached.
|
# In case the partition is cached.
|
||||||
@ -330,8 +330,8 @@ class DODB::CachedPartition(V) < DODB::Partition(V)
|
|||||||
# ```
|
# ```
|
||||||
# TODO: in case the partition is left empty, should the partition be removed from the cache?
|
# TODO: in case the partition is left empty, should the partition be removed from the cache?
|
||||||
def delete(partition : String, &matcher : Proc(V, Bool))
|
def delete(partition : String, &matcher : Proc(V, Bool))
|
||||||
# Use `get_with_indexes` to retrieve data on-disk, if necessary.
|
# Use `get_with_keys` to retrieve data on-disk, if necessary.
|
||||||
new_partition = get_with_indexes(partition).map(&.[1]).select do |key|
|
new_partition = get_with_keys(partition).map(&.[1]).select do |key|
|
||||||
item = @storage[key]
|
item = @storage[key]
|
||||||
! yield item
|
! yield item
|
||||||
end
|
end
|
||||||
@ -386,14 +386,14 @@ class DODB::RAMOnlyPartition(V) < DODB::CachedPartition(V)
|
|||||||
#
|
#
|
||||||
# ```
|
# ```
|
||||||
# # Get all red cars.
|
# # Get all red cars.
|
||||||
# cars_by_color.get_with_indexes "red"
|
# cars_by_color.get_with_keys "red"
|
||||||
# # Returns something like:
|
# # Returns something like:
|
||||||
# # [ (@storage[42], 42)
|
# # [ (@storage[42], 42)
|
||||||
# # , (@storage[91], 91)
|
# # , (@storage[91], 91)
|
||||||
# # ]
|
# # ]
|
||||||
# # Each tuple is composed of a car and its key in the database.
|
# # Each tuple is composed of a car and its key in the database.
|
||||||
# ```
|
# ```
|
||||||
def get_with_indexes(partition : String) : Array(Tuple(V, Int32))
|
def get_with_keys(partition : String) : Array(Tuple(V, Int32))
|
||||||
r_value = Array(Tuple(V, Int32)).new
|
r_value = Array(Tuple(V, Int32)).new
|
||||||
if keys = @data[partition]?
|
if keys = @data[partition]?
|
||||||
keys.each do |data_key|
|
keys.each do |data_key|
|
||||||
|
Loading…
Reference in New Issue
Block a user