Permalink
Browse files

unifying example scripts and utility classes

  • Loading branch information...
1 parent c18627b commit 45b50bf9bebb84c3cbfbc49513cfee43031cb9a3 Philip (flip) Kromer committed Jan 29, 2011
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
Dir[File.dirname(__FILE__)+'/vendor/**/lib'].each{|dir| $: << dir }
require 'rubygems'
-require 'wukong'
+require 'wukong/script'
require 'wukong/script/emr_command'
#
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-$: << '/home/flip/ics/wukong/lib' # ENV['WUKONG_PATH']
-require 'wukong'
+$: << File.dirname(__FILE__)+'/../lib'
+require 'wukong/script'
#
# Given an adjacency pairs (from \t to) representation of a directed graph:
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-$: << File.dirname(__FILE__)+'/../lib'
+$: << File.dirname(__FILE__)+'/../../lib'
require 'wukong/script'
require 'wukong/streamer/count_keys'
@@ -15,10 +15,6 @@ module Streamer
#
class AccumulatingReducer < Wukong::Streamer::Base
attr_accessor :key
- def initialize options
- super options
- self.key = :__first_pass__
- end
#
# override for multiple-field keys, etc.
@@ -72,6 +68,11 @@ def accumulate *args, &block
def finalize
end
+ # make a sentinel
+ def before_stream
+ self.key = :__first_pass__
+ end
+
# Finalize the last-seen group.
def after_stream *args
finalize(){|record| emit record } unless (self.key == :__first_pass__)

0 comments on commit 45b50bf

Please sign in to comment.