class Groonga::Command::Load
Attributes
columns[W]
table[W]
values[W]
Public Class Methods
command_name()
click to toggle source
# File lib/groonga/command/load.rb, line 30 def command_name "load" end
new(*argumetns)
click to toggle source
Calls superclass method
Groonga::Command::Base::new
# File lib/groonga/command/load.rb, line 52 def initialize(*argumetns) super @table = nil @values = nil @columns = nil end
parameter_names()
click to toggle source
# File lib/groonga/command/load.rb, line 34 def parameter_names [ :values, :table, :columns, :ifexists, :input_type, :each, :output_ids, ] end
Public Instance Methods
build_arrow_table()
click to toggle source
Builds `Arrow::Table` for data of this `load` command.
This requires red-arrow gem. If red-arrow gem isn't available, `NotImplementedError` is raised.
@return [Arrow::Table, nil] `Arrow::Table` if there is one or more
records, `nil` otherwise.
@since 1.4.6
# File lib/groonga/command/load.rb, line 83 def build_arrow_table unless defined?(::Arrow) raise NotImplementedError, "red-arrow is required" end source_lines = (original_source || "").lines if source_lines.size >= 2 if /\s--columns\s/ =~ source_lines.first target_columns = columns else target_columns = nil end target_values = JSON.parse(source_lines[1..-1].join("")) else target_columns = columns target_values = values end builder = ArrowTableBuilder.new(target_columns, target_values) builder.build end
columns()
click to toggle source
# File lib/groonga/command/load.rb, line 70 def columns @columns ||= parse_columns(self[:columns]) end
output_ids?()
click to toggle source
@return [Boolean] `true` if `output_ids` value is `“yes”`.
@since 1.3.0
# File lib/groonga/command/load.rb, line 106 def output_ids? boolean_value(:output_ids, default: false, invalid: false) end
table()
click to toggle source
@return [String] The table name to be loaded.
@since 1.3.5
# File lib/groonga/command/load.rb, line 62 def table @table ||= self[:table] end
values()
click to toggle source
# File lib/groonga/command/load.rb, line 66 def values @values ||= parse_values(self[:values]) end
Private Instance Methods
parse_columns(columns)
click to toggle source
# File lib/groonga/command/load.rb, line 118 def parse_columns(columns) return columns if columns.nil? columns.split(/\s*,\s*/) end
parse_values(values)
click to toggle source
# File lib/groonga/command/load.rb, line 113 def parse_values(values) return values if values.nil? JSON.parse(values) end