| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
require "fileutils" |
| 27 |
require "json" |
| 28 |
|
| 29 |
def check_max_index(options) |
| 30 |
max_n_segments = options[:max_n_segments] |
| 31 |
max_n_chunks = options[:max_n_chunks] |
| 32 |
n_patterns = options[:n_patterns] || 2 |
| 33 |
|
| 34 |
ENV["GRN_II_MAX_N_SEGMENTS_SMALL"] = max_n_segments&.to_s |
| 35 |
ENV["GRN_II_MAX_N_CHUNKS_SMALL"] = max_n_chunks&.to_s |
| 36 |
|
| 37 |
db_dir = "/dev/shm/db" |
| 38 |
log_path = "#{db_dir}/log" |
| 39 |
FileUtils.rm_rf(db_dir) |
| 40 |
FileUtils.mkdir_p(db_dir) |
| 41 |
command_line = [ |
| 42 |
"groonga", |
| 43 |
"--log-path", log_path, |
| 44 |
"-n", "#{db_dir}/db", |
| 45 |
] |
| 46 |
IO.popen(command_line, "r+") do |groonga| |
| 47 |
groonga.puts("table_create x TABLE_HASH_KEY UInt32") |
| 48 |
groonga.gets |
| 49 |
groonga.puts("column_create x y COLUMN_SCALAR UInt32") |
| 50 |
groonga.gets |
| 51 |
groonga.puts("table_create a TABLE_PAT_KEY UInt32") |
| 52 |
groonga.gets |
| 53 |
groonga.puts("column_create a b COLUMN_INDEX|INDEX_SMALL x y") |
| 54 |
groonga.gets |
| 55 |
|
| 56 |
groonga.puts("load --table x") |
| 57 |
groonga.puts("[") |
| 58 |
File.open(log_path) do |log| |
| 59 |
log.seek(0, IO::SEEK_END) |
| 60 |
log_size = log.size |
| 61 |
i = 0 |
| 62 |
catch do |abort| |
| 63 |
loop do |
| 64 |
y = i + 1 |
| 65 |
n_patterns.times do |
| 66 |
groonga.print(JSON.generate({"_key" => i, "y" => y})) |
| 67 |
groonga.puts(",") |
| 68 |
groonga.flush |
| 69 |
i += 1 |
| 70 |
if log.size != log_size |
| 71 |
data = log.read |
| 72 |
if /\|[Ae]\|/ =~ data |
| 73 |
parameters = [ |
| 74 |
max_n_segments.inspect, |
| 75 |
max_n_chunks.inspect, |
| 76 |
n_patterns.inspect, |
| 77 |
i, |
| 78 |
] |
| 79 |
puts(parameters.join("\t")) |
| 80 |
|
| 81 |
throw(abort) |
| 82 |
end |
| 83 |
log_size = log.size |
| 84 |
end |
| 85 |
end |
| 86 |
end |
| 87 |
end |
| 88 |
end |
| 89 |
groonga.puts("]") |
| 90 |
load_response = groonga.gets |
| 91 |
|
| 92 |
|
| 93 |
groonga.puts("quit") |
| 94 |
groonga.gets |
| 95 |
end |
| 96 |
end |
| 97 |
|
| 98 |
puts("N segments\tN chunks\tN patterns\tN records") |
| 99 |
[ |
| 100 |
[1, 1, 2], |
| 101 |
[2, 2, 2], |
| 102 |
[4, 4, 2], |
| 103 |
[8, 8, 2], |
| 104 |
[16, 16, 2], |
| 105 |
[32, 32, 2], |
| 106 |
[64, 64, 2], |
| 107 |
[128, 128, 2], |
| 108 |
[256, 256, 2], |
| 109 |
[512, 512, 2], |
| 110 |
[nil, nil, 1], |
| 111 |
[nil, nil, 2], |
| 112 |
[nil, nil, 4], |
| 113 |
[nil, nil, 8], |
| 114 |
[nil, nil, 16], |
| 115 |
[nil, nil, 32], |
| 116 |
[nil, nil, 64], |
| 117 |
[nil, nil, 128], |
| 118 |
[nil, nil, 256], |
| 119 |
].each do |max_n_segments, max_n_chunks, n_parameters| |
| 120 |
check_max_index(:max_n_segments => max_n_segments, |
| 121 |
:max_n_chunks => max_n_chunks, |
| 122 |
:n_patterns => n_parameters) |
| 123 |
end |