Class: HadoopDsl::HiveLike::HiveLikeMapper

Inherits:
BaseMapper show all
Includes:
HiveLikeMapRed
Defined in:
lib/hive_like.rb

Instance Attribute Summary

Attributes inherited from BaseMapRed

#emitted

Instance Method Summary collapse

Methods included from HiveLikeMapRed

#pre_process, #sprit_and_marge_args

Methods inherited from BaseMapper

#identity

Methods inherited from BaseMapRed

#emit

Methods included from DslController

#pre_process, #run

Methods included from DslElement

#method_missing

Constructor Details

#initialize(script, key, value) ⇒ HiveLikeMapper

Returns a new instance of HiveLikeMapper.



48
49
50
# File 'lib/hive_like.rb', line 48

def initialize(script, key, value)
  super(script, HiveLikeMapperModel.new(key, value))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HadoopDsl::DslElement

Instance Method Details

#select(*args) ⇒ Object

emitters



57
58
59
60
61
62
63
64
65
66
# File 'lib/hive_like.rb', line 57

def select(*args)
  from_index = args.index('from')
  if from_index
    values = args[0...from_index].map do |column|
      splitted = @model.value.split(/[,\s]+/)
      splitted[@model.table.columns.index(column)]
    end
    emit(args[from_index + 1] => values.join(", "))
  end
end