[Groonga-commit] groonga/groonga at 4a22a30 [master] tool: add support for infinite data generation

Back to archive index
Kouhei Sutou null+****@clear*****
Fri Apr 5 10:43:33 JST 2019


Kouhei Sutou	2019-04-05 10:43:33 +0900 (Fri, 05 Apr 2019)

  Revision: 4a22a3060319137d4fa75fb611bf449d2c4adae8
  https://github.com/groonga/groonga/commit/4a22a3060319137d4fa75fb611bf449d2c4adae8

  Message:
    tool: add support for infinite data generation

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

  Modified: tools/generate-long-posting-list-data.rb (+13 -4)
===================================================================
--- tools/generate-long-posting-list-data.rb    2019-04-04 12:59:22 +0900 (134f8e029)
+++ tools/generate-long-posting-list-data.rb    2019-04-05 10:43:33 +0900 (d660eb12c)
@@ -20,15 +20,24 @@ require "optparse"
 
 n_records = 100000
 use_section = false
+content = "XX XX XX"
 parser = OptionParser.new
 parser.on("--n-records=N", Integer,
           "[#{n_records}]") do |n|
-  n_records = n
+  if n < 0
+    n_records = Float::INFINITY
+  else
+    n_records = n
+  end
 end
 parser.on("--[no-]use-section",
           "[#{use_section}]") do |boolean|
   use_section = boolean
 end
+parser.on("--content=CONTENT",
+          "[#{content}]") do |_content|
+  content = _content
+end
 parser.parse!
 
 if use_section
@@ -61,10 +70,10 @@ puts(<<-LOAD)
 load --table Data
 [
 LOAD
-n_records.times do
-  record = {}
+(1..n_records).each do |id|
+  record = {"_id" => id}
   columns.each do |column|
-    record[column] = "XX XX XX"
+    record[column] = content
   end
   puts(record.to_json)
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190405/119683a1/attachment.html>


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