Rewrites lead to a working spec file.
parent
dd7ed3010d
commit
5bf6b21d5d
12
src/dodb.cr
12
src/dodb.cr
|
@ -274,23 +274,17 @@ abstract class DODB::Storage(V)
|
||||||
|
|
||||||
private def remove_indexing!
|
private def remove_indexing!
|
||||||
@indexers.each do |indexer|
|
@indexers.each do |indexer|
|
||||||
FileUtils.rm_rf indexer.indexing_directory
|
indexer.nuke_index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A very slow operation that removes all indices and then rewrites
|
# A very slow operation that removes all indices and then rewrites
|
||||||
# them all.
|
# them all.
|
||||||
# FIXME: Is this really useful in its current form? We should remove the
|
|
||||||
# index directories, not the indices based on our current (and
|
|
||||||
# possiblly different from what’s stored) data.
|
|
||||||
def reindex_everything!
|
def reindex_everything!
|
||||||
old_data = to_h
|
|
||||||
|
|
||||||
remove_indexing!
|
remove_indexing!
|
||||||
remove_data!
|
|
||||||
|
|
||||||
old_data.each do |index, item|
|
each_with_index() do |item, index|
|
||||||
self[index] = item
|
write_partitions index, item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,11 @@ class DODB::CachedIndex(V) < DODB::Index(V)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nuke_index
|
||||||
|
super
|
||||||
|
data.clear
|
||||||
|
end
|
||||||
|
|
||||||
def index(key, value)
|
def index(key, value)
|
||||||
super(key, value)
|
super(key, value)
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,9 @@ abstract class DODB::Indexer(V)
|
||||||
abstract def name : String
|
abstract def name : String
|
||||||
|
|
||||||
abstract def indexing_directory : String
|
abstract def indexing_directory : String
|
||||||
|
|
||||||
|
def nuke_index
|
||||||
|
FileUtils.rm_rf indexing_directory
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,11 @@ class DODB::CachedPartition(V) < DODB::Partition(V)
|
||||||
# This hash contains the relation between the index key and the data keys.
|
# This hash contains the relation between the index key and the data keys.
|
||||||
property data = Hash(String, Array(Int32)).new
|
property data = Hash(String, Array(Int32)).new
|
||||||
|
|
||||||
|
def nuke_index
|
||||||
|
super
|
||||||
|
data.clear
|
||||||
|
end
|
||||||
|
|
||||||
def index(key, value)
|
def index(key, value)
|
||||||
super(key, value)
|
super(key, value)
|
||||||
partition = key_proc.call value
|
partition = key_proc.call value
|
||||||
|
|
|
@ -157,6 +157,11 @@ class DODB::CachedTags(V) < DODB::Tags(V)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nuke_index
|
||||||
|
super
|
||||||
|
data.clear
|
||||||
|
end
|
||||||
|
|
||||||
def get_with_indice(tag : String) : Array(Tuple(V, Int32))
|
def get_with_indice(tag : String) : Array(Tuple(V, Int32))
|
||||||
r_value = Array(Tuple(V, Int32)).new
|
r_value = Array(Tuple(V, Int32)).new
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue