Class: Wukong::Decorator

Inherits:
EventSinkDecorator
  • Object
show all
Defined in:
lib/wukong/decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(mapper, reducer = nil, options = {}) ⇒ Decorator

Returns a new instance of Decorator.



10
11
12
13
# File 'lib/wukong/decorator.rb', line 10

def initialize(mapper, reducer=nil, options={})
  super(nil)
  @mapper = mapper.new
end

Instance Method Details

#append(e) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/wukong/decorator.rb', line 15

def append(e)
  line   = String.from_java_bytes(e.getBody)
  record = @mapper.recordize(line.chomp)
  @mapper.process(*record) do |output|
    processed = output.to_flat.join("\t")
    event     = EventImpl.new(processed.to_java_bytes, e.getTimestamp, e.getPriority, e.getNanos, e.getHost, e.getAttrs)
    super event
  end
end

#runObject



25
# File 'lib/wukong/decorator.rb', line 25

def run() self ; end