From 10448d6b0b2c28e12d41de295a92b2f6e3af1a71 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sat, 28 Dec 2019 03:24:05 +0100 Subject: [PATCH] Finalizes the DataBase(K, V) -> DataBase(V) change. --- spec/test.cr | 4 ++-- src/dodb.cr | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/test.cr b/spec/test.cr index bc917c2..e9808a3 100644 --- a/spec/test.cr +++ b/spec/test.cr @@ -88,7 +88,7 @@ class PrimitiveShip ] end -class DODB::SpecDataBase < DODB::DataBase(String, Ship) +class DODB::SpecDataBase < DODB::DataBase(Ship) def initialize(storage_ext = "") storage_dir = "test-storage#{storage_ext}" @@ -306,7 +306,7 @@ describe "DODB::DataBase" do end it "migrates properly" do - old_db = DODB::DataBase(String, PrimitiveShip).new "test-storage-migration-origin" + old_db = DODB::DataBase(PrimitiveShip).new "test-storage-migration-origin" old_ships_by_name = old_db.new_index "name", &.name old_ships_by_class = old_db.new_partition "class", &.class_name diff --git a/src/dodb.cr b/src/dodb.cr index f299cb5..5ea5994 100644 --- a/src/dodb.cr +++ b/src/dodb.cr @@ -3,7 +3,7 @@ require "json" require "./dodb/*" -class DODB::DataBase(K, V) +class DODB::DataBase(V) @indexers = [] of Indexer(V) def initialize(@directory_name : String) @@ -67,14 +67,13 @@ class DODB::DataBase(K, V) index.not_nil!.as(DODB::Index).get key end - # FIXME: Is this “key” really a K, not just a String? def get_partition(table_name : String, partition_name : String) partition = @indexers.find &.name.==(table_name) partition.not_nil!.as(DODB::Partition).get partition_name end - def get_tags(name, key : K) + def get_tags(name, key : String) partition = @indexers.find &.name.==(name) partition.not_nil!.as(DODB::Tags).get name, key