From fbdb451f0ee0e8dae78245241fdd6415db3eb367 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Wed, 8 May 2024 22:43:15 +0200 Subject: [PATCH] Block captures fixed. --- src/dodb/partition.cr | 11 +++++++---- src/dodb/tags.cr | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/dodb/partition.cr b/src/dodb/partition.cr index cfcafb8..0880386 100644 --- a/src/dodb/partition.cr +++ b/src/dodb/partition.cr @@ -66,7 +66,7 @@ class DODB::Partition(V) < DODB::Indexer(V) delete partition, do true end end - def delete(partition, &matcher) + def delete(partition, &matcher : Proc(V, Bool)) partition_directory = indexing_directory partition return unless Dir.exists? partition_directory @@ -155,7 +155,7 @@ class DODB::CachedPartition(V) < DODB::Partition(V) get_with_indexes(partition).map &.[0] end - def delete(partition, &matcher) + def delete(partition, &matcher : Proc(V, Bool)) # Use `get_with_indexes` to retrieve data on-disk, if necessary. new_partition = get_with_indexes(partition).map(&.[1]).select do |key| item = @storage[key] @@ -164,10 +164,13 @@ class DODB::CachedPartition(V) < DODB::Partition(V) @data[partition] = new_partition - super(partition, matcher) + super(partition, &matcher) end end +# `DODB::RAMOnlyPartition` enables the flexibility of partitions without a file-system representation. +# Absolute efficiency, exactly as easy to use as the other partition implementations. + class DODB::RAMOnlyPartition(V) < DODB::CachedPartition(V) def index(key, value) partition = key_proc.call value @@ -202,7 +205,7 @@ class DODB::RAMOnlyPartition(V) < DODB::CachedPartition(V) r_value end - def delete(partition, &matcher) + def delete(partition, &matcher : Proc(V, Bool)) if keys = @data[partition]? new_partition = keys.select do |key| item = @storage[key] diff --git a/src/dodb/tags.cr b/src/dodb/tags.cr index 48113fc..d4a31e2 100644 --- a/src/dodb/tags.cr +++ b/src/dodb/tags.cr @@ -181,11 +181,13 @@ class DODB::CachedTags(V) < DODB::Tags(V) @data[tag] = new_tag - super(tag, matcher) + super(tag, &matcher) end end -# TODO +# `DODB::RAMOnlyTags` enables the flexibility of tags without a file-system representation. +# Absolute efficiency, exactly as easy to use as the other tag implementations. + class DODB::RAMOnlyTags(V) < DODB::CachedTags(V) def index(key, value) indices = key_proc.call value