Sha256: 1dbeb069a886e1f4cb23b4e7556d0d66edc5bd241db25d9af60278a755dc0ba5

Contents?: true

Size: 812 Bytes

Versions: 16

Compression:

Stored size: 812 Bytes

Contents

module Wukong
  module Streamer
    #
    # Roll up all records from a given key into a single list.
    #
    class ListReducer < Wukong::Streamer::AccumulatingReducer
      attr_accessor :values

      # start with an empty list
      def start! *args
        self.values = []
      end

      # aggregate all records.
      # note that this accumulates the full *record* -- key, value, everything.
      def accumulate *record
        self.values << record
      end

      # emit the key and all records, tab-separated
      #
      # you will almost certainly want to override this method to do something
      # interesting with the values (or override accumulate to gather scalar
      # values)
      #
      def finalize
        yield [key, values.to_flat.join(";")].flatten
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
wukong-1.5.4 lib/wukong/streamer/list_reducer.rb
wukong-1.5.3 lib/wukong/streamer/list_reducer.rb
wukong-1.5.2 lib/wukong/streamer/list_reducer.rb
wukong-1.5.1 lib/wukong/streamer/list_reducer.rb
wukong-1.5.0 lib/wukong/streamer/list_reducer.rb
wukong-1.4.12 lib/wukong/streamer/list_reducer.rb
wukong-1.4.11 lib/wukong/streamer/list_reducer.rb
wukong-1.4.10 lib/wukong/streamer/list_reducer.rb
wukong-1.4.9 lib/wukong/streamer/list_reducer.rb
wukong-1.4.7 lib/wukong/streamer/list_reducer.rb
wukong-1.4.6 lib/wukong/streamer/list_reducer.rb
wukong-1.4.5 lib/wukong/streamer/list_reducer.rb
wukong-1.4.2 lib/wukong/streamer/list_reducer.rb
wukong-1.4.1 lib/wukong/streamer/list_reducer.rb
wukong-1.4.0 lib/wukong/streamer/list_reducer.rb
wukong-0.1.4 lib/wukong/streamer/list_reducer.rb