Class: Groonga::Client::CommandProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/client/command-processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, options = {}) ⇒ CommandProcessor

Returns a new instance of CommandProcessor.



24
25
26
27
28
29
30
31
32
33
# File 'lib/groonga/client/command-processor.rb', line 24

def initialize(client, options={})
  @client = client
  @split_load_chunk_size = options[:split_load_chunk_size] || 10000
  @generate_request_id   = options[:generate_request_id]
  @target_commands       = options[:target_commands] || []
  @target_tables         = options[:target_tables] || []
  @target_columns        = options[:target_columns] || []
  @load_values = []
  @parser = create_command_parser
end

Instance Method Details

#<<(line) ⇒ Object



35
36
37
# File 'lib/groonga/client/command-processor.rb', line 35

def <<(line)
  @parser << line
end

#consume(input) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/groonga/client/command-processor.rb', line 43

def consume(input)
  last_line = nil
  input.each_line do |line|
    last_line = line
    @parser << line
  end
  if last_line and not last_line.end_with?("\n")
    @parser << "\n"
  end
end

#finishObject



39
40
41
# File 'lib/groonga/client/command-processor.rb', line 39

def finish
  @parser.finish
end

#load(path) ⇒ Object



54
55
56
57
58
# File 'lib/groonga/client/command-processor.rb', line 54

def load(path)
  File.open(path) do |input|
    consume(input)
  end
end