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.



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

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.



172
173
174
# File 'lib/groonga-delta/mapping.rb', line 172

def expression
  @expression
end

#nameObject (readonly)

Returns the value of attribute name.



170
171
172
# File 'lib/groonga-delta/mapping.rb', line 170

def name
  @name
end

#restrictionObject (readonly)

Returns the value of attribute restriction.



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

def restriction
  @restriction
end

#templateObject (readonly)

Returns the value of attribute template.



171
172
173
# File 'lib/groonga-delta/mapping.rb', line 171

def template
  @template
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#arrow_typeObject



193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/groonga-delta/mapping.rb', line 193

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



183
184
185
186
187
188
189
190
191
# File 'lib/groonga-delta/mapping.rb', line 183

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