Sha256: 14ac1b481ae4d2c7c3930be955687ef6532b4019616f7fdf3769756ea3ce746f

Contents?: true

Size: 530 Bytes

Versions: 19

Compression:

Stored size: 530 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'wukong'
require 'wukong/streamer/summing_reducer'

#
#
class Summer < Wukong::Streamer::SummingReducer
  attr_accessor :sample_line

  def initialize *args
    self.summing_elements = [0]
    super *args
  end

  def start! *args
    self.sample_line = args
    super *args
  end

  def get_key *fields
    fields.values_at(2,3)
  end

  def finalize
    summing_elements.each{|idx| sample_line[idx] = sums[idx]}
    yield sample_line
  end
end

Wukong::Script.new(Summer, nil).run

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
ul-wukong-4.1.1 bin/wu-sum
ul-wukong-4.1.0 bin/wu-sum
wukong-4.0.0 bin/wu-sum
wukong-3.0.1 bin/wu-sum
wukong-3.0.0 bin/wu-sum
wukong-3.0.0.pre3 bin/wu-sum
wukong-3.0.0.pre2 bin/wu-sum
wukong-3.0.0.pre bin/wu-sum
wukong-2.0.2 bin/wu-sum
wukong-2.0.1 bin/wu-sum
wukong-2.0.0 bin/wu-sum
wukong-1.5.4 bin/wu-sum
wukong-1.5.3 bin/wu-sum
wukong-1.5.2 bin/wu-sum
wukong-1.5.1 bin/wu-sum
wukong-1.5.0 bin/wu-sum
wukong-1.4.12 bin/wu-sum
wukong-1.4.11 bin/wu-sum
wukong-1.4.10 bin/wu-sum