Class: Groonga::Command::Load
Defined Under Namespace
Classes: ArrowTableBuilder
Instance Attribute Summary collapse
- #columns ⇒ Object
-
#table ⇒ String
The table name to be loaded.
- #values ⇒ Object
Attributes inherited from Base
#arguments, #command_name, #original_format, #original_source, #path_prefix
Class Method Summary collapse
Instance Method Summary collapse
-
#build_arrow_table ⇒ Arrow::Table?
Builds
Arrow::Table
for data of thisload
command. -
#initialize(*argumetns) ⇒ Load
constructor
A new instance of Load.
-
#output_ids? ⇒ Boolean
true
ifoutput_ids
value is"yes"
.
Methods inherited from Base
#==, #[], #[]=, #command_format?, #key?, #name, #output_type, #request_id, #to_command_format, #to_elasticsearch_format, #to_s, #to_uri_format, #uri_format?
Constructor Details
#initialize(*argumetns) ⇒ Load
Returns a new instance of Load.
52 53 54 55 56 57 |
# File 'lib/groonga/command/load.rb', line 52 def initialize(*argumetns) super @table = nil @values = nil @columns = nil end |
Instance Attribute Details
#columns ⇒ Object
70 71 72 |
# File 'lib/groonga/command/load.rb', line 70 def columns @columns ||= parse_columns(self[:columns]) end |
#table ⇒ String
Returns The table name to be loaded.
62 63 64 |
# File 'lib/groonga/command/load.rb', line 62 def table @table ||= self[:table] end |
#values ⇒ Object
66 67 68 |
# File 'lib/groonga/command/load.rb', line 66 def values @values ||= parse_values(self[:values]) end |
Class Method Details
.command_name ⇒ Object
30 31 32 |
# File 'lib/groonga/command/load.rb', line 30 def command_name "load" end |
.parameter_names ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/groonga/command/load.rb', line 34 def parameter_names [ :values, :table, :columns, :ifexists, :input_type, :each, :output_ids, ] end |
Instance Method Details
#build_arrow_table ⇒ Arrow::Table?
Builds Arrow::Table
for data of this load
command.
This requires red-arrow gem. If red-arrow gem isn't available,
NotImplementedError
is raised.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# 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 |
#output_ids? ⇒ Boolean
Returns true
if output_ids
value is "yes"
.
106 107 108 109 110 |
# File 'lib/groonga/command/load.rb', line 106 def output_ids? boolean_value(:output_ids, default: false, invalid: false) end |