Version 0.8.0: gefaltete Indizes markiert, Review abgeschlossen

index -x schreibt Offset-x in den Kopf der .i-Datei, search bisektiert in
der Ordnung des Index. Beim Umstieg .h- und mit -x gebaute .i-Indizes neu
bauen.
This commit is contained in:
wkh
2026-10-30 10:13:59 +01:00
parent d6733e737e
commit 5020d7e982
7 changed files with 82 additions and 17 deletions
+40
View File
@@ -971,3 +971,43 @@ class JoinNumericTest < RdbCase
assert_equal 3, data(rdb('jointable', '-n', '-a1', 'j1', 'j2')).size
end
end
class FoldedIndexTest < RdbCase
def setup
super
write('fold', "K\tV\n-\t-\nb\t1\nApple\t2\nc\t3\napricot\t4\nB\t5\n")
end
def keys(out)
data(out).map(&:first).sort
end
def test_folded_index_is_marked_and_found_both_ways
rdb('index', '-mi', '-x', 'fold', 'K')
assert_equal "K\tOffset-x", read('fold.i').lines.first.chomp
assert_equal %w[Apple apricot], keys(rdb('search', '-mi', '-x', 'fold', 'K', stdin: "ap\n"))
assert_equal %w[c], keys(rdb('search', '-mi', 'fold', 'K', stdin: "c\n"))
assert_equal %w[B], keys(rdb('search', '-mi', 'fold', 'K', stdin: "B\n"))
end
def test_partial_search_in_a_plain_index_finds_every_case
rdb('index', '-mi', 'fold', 'K')
assert_equal "K\tOffset", read('fold.i').lines.first.chomp
assert_equal %w[B b], keys(rdb('search', '-mi', '-x', 'fold', 'K', stdin: "b\n"))
assert_equal %w[Apple apricot], keys(rdb('search', '-mi', '-x', 'fold', 'K', stdin: "AP\n"))
end
def test_append_keeps_a_folded_index_in_order
rdb('index', '-mi', '-x', 'fold', 'K')
rdb('append', '-mi', 'fold', 'K', stdin: "K\tV\n-\t-\nAzure\t6\n")
folded = read('fold.i').lines.drop(2).map { |l| l.split("\t").first.downcase }
assert_equal folded.sort, folded
assert_equal %w[Apple Azure apricot], keys(rdb('search', '-mi', '-x', 'fold', 'K', stdin: "a\n"))
end
def test_partial_search_on_a_sorted_table
rdb('index', '-mb', 'fold', 'K')
assert_equal %w[B b], keys(rdb('search', '-mb', '-x', 'fold', 'K', stdin: "b\n"))
assert_equal %w[b], keys(rdb('search', '-mb', 'fold', 'K', stdin: "b\n"))
end
end