Skip to content

Commit

Permalink
Changing time parsing to a method that is compatible across 1.8.6, 1.…
Browse files Browse the repository at this point in the history
…8.7, and 1.8.9
  • Loading branch information
amikula committed Jul 6, 2011
1 parent 976d479 commit 48b50ec
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions test/utest.rb
Expand Up @@ -15,7 +15,7 @@ def declare
field :date
field :time
field :url

emit :date_time
emit :url
end
Expand All @@ -25,7 +25,7 @@ def process(input, output)
output.url = input.url
output
end

end

class LogReduce < ReduceBase
Expand Down Expand Up @@ -58,7 +58,7 @@ class TestMRToolkit < Test::Unit::TestCase
def test_log
LogJob.run_command
out = File.read("test-out")
expected = "2008-10-01T10:30:00\t1.2.3.4\tx\n" +
expected = "2008-10-01T10:30:00\t1.2.3.4\tx\n" +
"2008-10-02T11:30:00\t1.2.3.5\tx\n"
assert_equal(expected, out)
end
Expand All @@ -72,7 +72,7 @@ def test_log
class SumMap < MapBase
def declare
field :value

emit :count
emit :total
emit :sum_of_squares
Expand All @@ -85,7 +85,7 @@ def process(input, output)
output.sum_of_squares = v * v
output
end

end

# This could be done with canned reducer
Expand Down Expand Up @@ -144,26 +144,25 @@ def test_sum
# Grops times into one-minute buckets
# Calculates counts for each bucket

require 'parsedate'
require 'time'

class MinMap < MapBase
def declare
field :dt
field :tm

emit :minute
emit :count
end

def process(input, output)
res = ParseDate.parsedate(input.dt + " " + input.tm)
t = Time.local(*res)
t = Time.parse(input.dt + " " + input.tm)
min = t.min + 60 * (t.hour + 24 * t.wday)
output.count = 1
output.minute = min
output
end

end

class MyMinReduce < ReduceBase
Expand Down Expand Up @@ -211,7 +210,7 @@ def test_min
end

#################################
#
#
# This is the previous one, but with a standard reducer.

class CollectJob < JobBase
Expand All @@ -237,7 +236,7 @@ def test_collect
end

#################################
#
#
# This is the previous one, but with adifferent
# standard reducer. This produces the same output
# as the custom reducer.
Expand Down

0 comments on commit 48b50ec

Please sign in to comment.