[Groonga-commit] ranguba/groonga-client at 1d99e39 [master] groonga-client: support split load

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Apr 20 18:30:09 JST 2015


Kouhei Sutou	2015-04-20 18:30:09 +0900 (Mon, 20 Apr 2015)

  New Revision: 1d99e39b98cada844b4dcb318a5ede0e9baf000f
  https://github.com/ranguba/groonga-client/commit/1d99e39b98cada844b4dcb318a5ede0e9baf000f

  Message:
    groonga-client: support split load

  Modified files:
    bin/groonga-client

  Modified: bin/groonga-client (+27 -5)
===================================================================
--- bin/groonga-client    2015-04-20 15:08:26 +0900 (23b4c65)
+++ bin/groonga-client    2015-04-20 18:30:09 +0900 (7ce5f13)
@@ -86,17 +86,39 @@ parser.on_command do |command|
   run_command(client, command)
 end
 
+split_load = true
+parser.on_load_start do |command|
+  if command[:values]
+    split_load = false
+  else
+    split_load = true
+  end
+end
 parser.on_load_columns do |command, columns|
   command[:columns] ||= columns.join(",")
 end
 values = []
-parser.on_load_value do |_, value|
-  values << value
+consume_values = lambda do |load_command|
+  return if values.empty?
+
+  load_command[:values] = Yajl::Encoder.encode(values)
+  run_command(client, load_command)
+  load_command.original_source.clear
+  values.clear
+  load_command[:values] = nil
+end
+parser.on_load_value do |command, value|
+  if split_load
+    values << value
+    consume_values.call(command) if values.size == 10000
+  end
 end
 parser.on_load_complete do |command|
-  command[:values] ||= Yajl::Encoder.encode(values)
-  run_command(client, command)
-  values.clear
+  if split_load
+    consume_values.call(command)
+  else
+    run_command(client, command)
+  end
 end
 
 if command_file_paths.empty?
-------------- next part --------------
HTML����������������������������...
Download 



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