Class: GroongaDelta::Mapping::GroongaColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-delta/mapping.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, template, expression, type, restriction) ⇒ GroongaColumn

Returns a new instance of GroongaColumn.



179
180
181
182
183
184
185
# File 'lib/groonga-delta/mapping.rb', line 179

def initialize(name, template, expression, type, restriction)
  @name = name
  @template = template
  @expression = expression
  @type = type
  @restriction = restriction
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



176
177
178
# File 'lib/groonga-delta/mapping.rb', line 176

def expression
  @expression
end

#nameObject (readonly)

Returns the value of attribute name.



174
175
176
# File 'lib/groonga-delta/mapping.rb', line 174

def name
  @name
end

#restrictionObject (readonly)

Returns the value of attribute restriction.



178
179
180
# File 'lib/groonga-delta/mapping.rb', line 178

def restriction
  @restriction
end

#templateObject (readonly)

Returns the value of attribute template.



175
176
177
# File 'lib/groonga-delta/mapping.rb', line 175

def template
  @template
end

#typeObject (readonly)

Returns the value of attribute type.



177
178
179
# File 'lib/groonga-delta/mapping.rb', line 177

def type
  @type
end

Instance Method Details

#arrow_typeObject



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/groonga-delta/mapping.rb', line 197

def arrow_type
  case @type
  when nil, "ShortText", "Text", "LongText"
    :string
  when "Bool"
    :boolean
  when "Time"
    Arrow::TimestampDataType.new(:nano)
  else
    @type
  end
end

#generate_value(source_record) ⇒ Object



187
188
189
190
191
192
193
194
195
# File 'lib/groonga-delta/mapping.rb', line 187

def generate_value(source_record)
  if @template
    value = cast(@template % source_record)
  else
    evaluator = ExpressionEvaluator.new(source_record)
    value = evaluator.evaluate(@expression)
  end
  normalize_value(value)
end