Test some reindex stuff with the Car database.
parent
835626a6dd
commit
0b4cdf00b7
|
@ -0,0 +1,45 @@
|
|||
require "spec"
|
||||
require "./benchmark-utilities.cr"
|
||||
require "./cars.cr"
|
||||
|
||||
corvet0 = Car.new "Corvet-0", "red", [ "shiny", "impressive", "fast", "elegant" ]
|
||||
|
||||
describe "DODB car" do
|
||||
describe "behavior of uncached, cached and ram indexes:" do
|
||||
it "RAM DB - add items, add indexes, search, reindex, search" do
|
||||
|
||||
cars_ram0 = DODB::RAMOnlySpecDataBase(Car).new "-0"
|
||||
cars_ram1 = DODB::RAMOnlySpecDataBase(Car).new "-1"
|
||||
cars_ram2 = DODB::RAMOnlySpecDataBase(Car).new "-2"
|
||||
|
||||
add_cars cars_ram0, 1
|
||||
add_cars cars_ram1, 1
|
||||
add_cars cars_ram2, 1
|
||||
|
||||
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
|
||||
|
||||
uncached_searchby_name.get?("Corvet-0").should be_nil
|
||||
cached_searchby_name.get?("Corvet-0").should be_nil
|
||||
ram_searchby_name.get?("Corvet-0").should be_nil
|
||||
|
||||
cars_ram0.reindex_everything!
|
||||
cars_ram1.reindex_everything!
|
||||
cars_ram2.reindex_everything!
|
||||
|
||||
# Cannot get the value since it's not written on disk.
|
||||
# FIXME: should only retrieve the key with the index, not the actual value.
|
||||
# So, this should work.
|
||||
uncached_searchby_name.get?("Corvet-0").should be_nil
|
||||
|
||||
# Both cached and RAM indexes can retrieve the value since they store the key.
|
||||
cached_searchby_name.get?("Corvet-0").should eq corvet0
|
||||
ram_searchby_name.get?("Corvet-0").should eq corvet0
|
||||
|
||||
cars_ram0.rm_storage_dir
|
||||
cars_ram1.rm_storage_dir
|
||||
cars_ram2.rm_storage_dir
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue