[Groonga-commit] groonga/groonga at c146542 [master] Add --use-section

Back to archive index
Kouhei Sutou null+****@clear*****
Fri Jan 18 18:14:52 JST 2019


Kouhei Sutou	2019-01-18 18:14:52 +0900 (Fri, 18 Jan 2019)

  Revision: c146542a4905b5716d6713165ab858195a468d3b
  https://github.com/groonga/groonga/commit/c146542a4905b5716d6713165ab858195a468d3b

  Message:
    Add --use-section

  Modified files:
    tools/generate-long-posting-list-data.rb

  Modified: tools/generate-long-posting-list-data.rb (+28 -3)
===================================================================
--- tools/generate-long-posting-list-data.rb    2019-01-18 17:48:30 +0900 (cd24d3cbb)
+++ tools/generate-long-posting-list-data.rb    2019-01-18 18:14:52 +0900 (10e3ce351)
@@ -4,21 +4,42 @@ require "json"
 require "optparse"
 
 n_records = 100000
+use_section = false
 parser = OptionParser.new
 parser.on("--n-records=N", Integer,
           "[#{n_records}]") do |n|
   n_records = n
 end
+parser.on("--[no-]use-section",
+          "[#{use_section}]") do |boolean|
+  use_section = boolean
+end
 parser.parse!
 
+if use_section
+  columns = 5.times {|i| "value#{i}"}
+else
+  columns = ["value"]
+end
+
 puts(<<-COMMANDS)
 table_create Data TABLE_NO_KEY
-column_create Data value COLUMN_SCALAR Text
+COMMANDS
+columns.each do |column|
+  puts(<<-COMMANDS)
+column_create Data #{column} COLUMN_SCALAR Text
+  COMMANDS
+end
 
+index_column_flags = "COLUMN_INDEX|WITH_POSITION"
+if columns.size > 1
+  index_column_flags += "|WITH_SECTION"
+end
+puts(<<-COMMANDS)
 table_create Terms TABLE_PAT_KEY ShortText \
   --normalizer NormalizerNFKC100 \
   --default_tokenizer TokenRegexp
-column_create Terms index COLUMN_INDEX|WITH_POSITION Data value
+column_create Terms index #{index_column_flags} Data #{columns.join(",")}
 COMMANDS
 
 puts(<<-LOAD)
@@ -26,7 +47,11 @@ load --table Data
 [
 LOAD
 n_records.times do
-  puts({"value" => "X"}.to_json)
+  record = {}
+  columns.each do |column|
+    record[column] = "X"
+  end
+  puts(record.to_json)
 end
 puts(<<-LOAD)
 ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190118/286b432c/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index