Sha256: d7e67fae60951d530afd2851922747432eb54e9bad0c8bfa9b35fbe8fb3e9af9

Contents?: true

Size: 727 Bytes

Versions: 6

Compression:

Stored size: 727 Bytes

Contents

#!/usr/bin/env ruby
require_relative './common'

# cat data/swk-100.tsv      | ./histograms.rb --map | sort > data/swk-hist-map.tsv
# cat data/swk-hist-map.tsv | ./histograms.rb --reduce     > data/swk-hist.tsv

class HistogramsMapper < Wukong::Streamer::ModelStreamer
  self.model_klass = Logline
  def process visit
    yield [visit.path, visit.day_hr]
  end
end

class HistogramsReducer < Wukong::Streamer::Reducer
  def get_key(path, day_hr)
    [path, day_hr]
  end
  def start!(*args)
    @count = 0
    super
  end
  def accumulate(path, day_hr)
    @count += 1
  end
  def finalize
    yield [key, @count]
  end
end

# Wukong.run( HistogramsMapper )
Wukong.run( HistogramsMapper, HistogramsReducer, :sort_fields => 3 )

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ul-wukong-4.1.1 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb
ul-wukong-4.1.0 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb
wukong-4.0.0 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb
wukong-3.0.1 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb
wukong-3.0.0 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb
wukong-3.0.0.pre3 examples/serverlogs/visit_paths/serverlogs-02-histograms-full.rb