New consistency verification for indexes.

This commit is contained in:
Philippe PITTOLI 2024-05-22 05:34:14 +02:00
parent 8ee628d640
commit 255cfe4162
2 changed files with 48 additions and 0 deletions

View File

@ -28,6 +28,11 @@ class Car
def ==(other) def ==(other)
@name == other.name && @color == other.color && @keywords == other.keywords @name == other.name && @color == other.color && @keywords == other.keywords
end end
# Equality is true if every property is identical.
def <=>(other)
@name <=> other.name
end
end end
def ram_indexes(storage : DODB::Storage) def ram_indexes(storage : DODB::Storage)

View File

@ -39,3 +39,46 @@ describe "uncached, cached and ram indexes" do
cars_ram2.rm_storage_dir cars_ram2.rm_storage_dir
end end
end end
describe "tracking inconsistencies between implementations" do
it "index - partitions - tags" do
cars_ram0 = DODB::RAMOnlySpecDataBase(Car).new "-0"
cars_ram1 = DODB::RAMOnlySpecDataBase(Car).new "-1"
cars_ram2 = DODB::RAMOnlySpecDataBase(Car).new "-2"
uncached_searchby_name, uncached_searchby_color, uncached_searchby_keywords = uncached_indexes cars_ram0
cached_searchby_name, cached_searchby_color, cached_searchby_keywords = cached_indexes cars_ram1
ram_searchby_name, ram_searchby_color, ram_searchby_keywords = ram_indexes cars_ram2
add_cars cars_ram0, 1
add_cars cars_ram1, 1
add_cars cars_ram2, 1
# Searches should be consistent between all implementations of basic indexes, partitions and tags.
# Basic index.
uncached_corvet_car = uncached_searchby_color.get_with_keys? "Corvet-0"
cached_corvet_car = cached_searchby_color.get_with_keys? "Corvet-0"
ram_corvet_car = ram_searchby_color.get_with_keys? "Corvet-0"
uncached_corvet_car.should eq cached_corvet_car
uncached_corvet_car.should eq ram_corvet_car
# Partitions.
uncached_red_cars = uncached_searchby_color.get? "red"
cached_red_cars = cached_searchby_color.get? "red"
ram_red_cars = ram_searchby_color.get? "red"
uncached_red_cars.sort.should eq cached_red_cars.sort
uncached_red_cars.sort.should eq ram_red_cars.sort
# Tags.
uncached_fast_cars = uncached_searchby_keywords.get? "fast"
cached_fast_cars = cached_searchby_keywords.get? "fast"
ram_fast_cars = ram_searchby_keywords.get? "fast"
uncached_fast_cars.sort.should eq cached_fast_cars.sort
uncached_fast_cars.sort.should eq ram_fast_cars.sort
cars_ram0.rm_storage_dir
cars_ram1.rm_storage_dir
cars_ram2.rm_storage_dir
end
end